DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
Loading...
Searching...
No Matches
gl_rmain.c File Reference
#include "quakedef.h"
#include "r_shadow.h"
#include "polygon.h"
#include "image.h"
#include "ft2.h"
#include "csprogs.h"
#include "cl_video.h"
#include "cl_collision.h"
#include "shader_glsl.h"

Go to the source code of this file.

Data Structures

struct  cubemapinfo_t
 
struct  r_qwskincache_t
 
struct  shaderpermutationinfo_t
 
struct  shadermodeinfo_t
 
struct  r_glsl_permutation_t
 
struct  r_skinframe_t
 
struct  suffixinfo_t
 
struct  r_framedata_mem_t
 
struct  r_bufferdata_buffer_t
 
struct  r_decalsystem_splatqueue_t
 

Macros

#define NORMSIZE   64
 
#define FOGWIDTH   256
 
#define SHADERPERMUTATION_HASHSIZE   256
 
#define SHADERSTATICPARMS_COUNT   15
 
#define R_COMPILESHADER_STATICPARM_ENABLE(p)   r_compileshader_staticparms[(p) >> 5] |= (1 << ((p) & 0x1F))
 
#define R_COMPILESHADER_STATICPARM_EMIT(p, n)
 
#define BLENDFUNC_ALLOWS_COLORMOD   1
 
#define BLENDFUNC_ALLOWS_FOG   2
 
#define BLENDFUNC_ALLOWS_FOG_HACK0   4
 
#define BLENDFUNC_ALLOWS_FOG_HACKALPHA   8
 
#define BLENDFUNC_ALLOWS_ANYFOG   (BLENDFUNC_ALLOWS_FOG | BLENDFUNC_ALLOWS_FOG_HACK0 | BLENDFUNC_ALLOWS_FOG_HACKALPHA)
 
#define SKINFRAME_HASH   1024
 
#define R_SKINFRAME_LOAD_AVERAGE_COLORS(cnt, getpixel)
 
#define R_BUFFERDATA_CYCLE   3
 
#define RAMPWIDTH   256
 
#define BBOXEDGES   13
 
#define R_MESH_PLANE_DIST_EPSILON   (1.0 / 32.0)
 

Enumerations

enum  {
  SHADERSTATICPARM_SATURATION_REDCOMPENSATE = 0 , SHADERSTATICPARM_EXACTSPECULARMATH = 1 , SHADERSTATICPARM_POSTPROCESS_USERVEC1 = 2 , SHADERSTATICPARM_POSTPROCESS_USERVEC2 = 3 ,
  SHADERSTATICPARM_POSTPROCESS_USERVEC3 = 4 , SHADERSTATICPARM_POSTPROCESS_USERVEC4 = 5 , SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS = 6 , SHADERSTATICPARM_OFFSETMAPPING_USELOD = 7 ,
  SHADERSTATICPARM_SHADOWMAPPCF_1 = 8 , SHADERSTATICPARM_SHADOWMAPPCF_2 = 9 , SHADERSTATICPARM_SHADOWSAMPLER = 10 , SHADERSTATICPARM_CELSHADING = 11 ,
  SHADERSTATICPARM_CELOUTLINES = 12 , SHADERSTATICPARM_FXAA = 13 , SHADERSTATICPARM_COLORFRINGE = 14
}
 

Functions

void R_ModulateColors (float *in, float *out, int verts, float r, float g, float b)
 
void R_FillColors (float *out, int verts, float r, float g, float b, float a)
 
void FOG_clear (void)
 
static void R_BuildBlankTextures (void)
 
static void R_BuildNoTexture (void)
 
static void R_BuildWhiteCube (void)
 
static void R_BuildNormalizationCube (void)
 
static void R_BuildFogTexture (void)
 
static void R_BuildFogHeightTexture (void)
 
qbool R_CompileShader_CheckStaticParms (void)
 
static void R_CompileShader_AddStaticParms (unsigned int mode, uint64_t permutation)
 
static r_glsl_permutation_tR_GLSL_FindPermutation (unsigned int mode, uint64_t permutation)
 
static charR_ShaderStrCat (const char **strings)
 
static void R_InitShaderModeInfo (void)
 
static charShaderModeInfo_GetShaderText (shadermodeinfo_t *modeinfo, qbool printfromdisknotice, qbool builtinonly)
 
static void R_GLSL_CompilePermutation (r_glsl_permutation_t *p, unsigned int mode, uint64_t permutation)
 
static void R_SetupShader_SetPermutationGLSL (unsigned int mode, uint64_t permutation)
 
void R_GLSL_Restart_f (cmd_state_t *cmd)
 
static void R_GLSL_DumpShader_f (cmd_state_t *cmd)
 
void R_SetupShader_Generic (rtexture_t *t, qbool usegamma, qbool notrippy, qbool suppresstexalpha)
 
void R_SetupShader_Generic_NoTexture (qbool usegamma, qbool notrippy)
 
void R_SetupShader_DepthOrShadow (qbool notrippy, qbool depthrgb, qbool skeletal)
 
static int R_BlendFuncFlags (int src, int dst)
 
void R_SetupShader_Surface (const float rtlightambient[3], const float rtlightdiffuse[3], const float rtlightspecular[3], rsurfacepass_t rsurfacepass, int texturenumsurfaces, const msurface_t **texturesurfacelist, void *surfacewaterplane, qbool notrippy, qbool ui)
 
void R_SetupShader_DeferredLight (const rtlight_t *rtlight)
 
void R_SkinFrame_PrepareForPurge (void)
 
void R_SkinFrame_MarkUsed (skinframe_t *skinframe)
 
void R_SkinFrame_PurgeSkinFrame (skinframe_t *s)
 
void R_SkinFrame_Purge (void)
 
skinframe_tR_SkinFrame_FindNextByName (skinframe_t *last, const char *name)
 
skinframe_tR_SkinFrame_Find (const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qbool add)
 
skinframe_tR_SkinFrame_LoadExternal (const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
 
skinframe_tR_SkinFrame_LoadExternal_SkinFrame (skinframe_t *skinframe, const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
 
skinframe_tR_SkinFrame_LoadInternalBGRA (const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qbool sRGB)
 
skinframe_tR_SkinFrame_LoadInternalQuake (const char *name, int textureflags, int loadpantsandshirt, int loadglowtexture, const unsigned char *skindata, int width, int height)
 
static void R_SkinFrame_GenerateTexturesFromQPixels (skinframe_t *skinframe, qbool colormapped)
 
skinframe_tR_SkinFrame_LoadInternal8bit (const char *name, int textureflags, const unsigned char *skindata, int width, int height, const unsigned int *palette, const unsigned int *alphapalette)
 
skinframe_tR_SkinFrame_LoadMissing (void)
 
skinframe_tR_SkinFrame_LoadNoTexture (void)
 
skinframe_tR_SkinFrame_LoadInternalUsingTexture (const char *name, int textureflags, rtexture_t *tex, int width, int height, qbool sRGB)
 
static rtexture_tR_LoadCubemap (const char *basename)
 
rtexture_tR_GetCubemap (const char *basename)
 
static void R_Main_FreeViewCache (void)
 
static void R_Main_ResizeViewCache (void)
 
static void gl_main_start (void)
 
static void gl_main_shutdown (void)
 
static void gl_main_newmap (void)
 
void GL_Main_Init (void)
 
void Render_Init (void)
 
static void R_GetCornerOfBox (vec3_t out, const vec3_t mins, const vec3_t maxs, int signbits)
 
static qbool _R_CullBox (const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes, int ignore)
 
qbool R_CullFrustum (const vec3_t mins, const vec3_t maxs)
 
qbool R_CullBox (const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes)
 
void R_FrameData_Reset (void)
 free all R_FrameData memory
 
static void R_FrameData_Resize (qbool mustgrow)
 
void R_FrameData_NewFrame (void)
 prepare for a new frame, recycles old buffers if a resize occurred previously
 
voidR_FrameData_Alloc (size_t size)
 allocate some temporary memory for your purposes
 
voidR_FrameData_Store (size_t size, void *data)
 allocate some temporary memory and copy this data into it
 
void R_FrameData_SetMark (void)
 set a marker that allows you to discard the following temporary memory allocations
 
void R_FrameData_ReturnToMark (void)
 discard recent memory allocations (rewind to marker)
 
void R_BufferData_Reset (void)
 frees all dynamic buffers
 
static void R_BufferData_Resize (r_bufferdata_type_t type, qbool mustgrow, size_t minsize)
 
void R_BufferData_NewFrame (void)
 begin a new frame (recycle old buffers)
 
r_meshbuffer_tR_BufferData_Store (size_t datasize, const void *data, r_bufferdata_type_t type, int *returnbufferoffset)
 request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and offset, always successful
 
void R_AnimCache_Free (void)
 Animation cache prevents re-generating mesh data for an animated model multiple times in one frame for lighting, shadowing, reflections, etc.
 
void R_AnimCache_ClearCache (void)
 clear the animcache pointers on all known render entities
 
qbool R_AnimCache_GetEntity (entity_render_t *ent, qbool wantnormals, qbool wanttangents)
 get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangents)
 
void R_AnimCache_CacheVisibleEntities (void)
 generate animcache data for all entities marked visible
 
qbool R_CanSeeBox (int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t entboxexpand, vec_t pad, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
 
static void R_View_UpdateEntityVisible (void)
 
static int R_DrawBrushModelsSky (void)
 only used if skyrendermasked, and normally returns false
 
static void R_DrawNoModel (entity_render_t *ent)
 
static void R_DrawModels (void)
 
static void R_DrawModelsDepth (void)
 
static void R_DrawModelsDebug (void)
 
static void R_DrawModelsAddWaterPlanes (void)
 
void R_HDR_UpdateIrisAdaptation (const vec3_t point)
 
static void R_View_SetFrustum (const int *scissor)
 
static void R_View_Update (const int *myscissor)
 
void R_SetupView (qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
void R_EntityMatrix (const matrix4x4_t *matrix)
 
void R_ResetViewRendering2D_Common (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight, float x2, float y2)
 
void R_ResetViewRendering2D (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
void R_ResetViewRendering3D (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
void R_RenderView_UpdateViewVectors (void)
 
void R_RenderTarget_FreeUnused (qbool force)
 
static void R_CalcTexCoordsForView (float x, float y, float w, float h, float tw, float th, float *texcoord2f)
 
r_rendertarget_tR_RenderTarget_Get (int texturewidth, int textureheight, textype_t depthtextype, qbool depthisrenderbuffer, textype_t colortextype0, textype_t colortextype1, textype_t colortextype2, textype_t colortextype3)
 
static void R_Water_StartFrame (int viewwidth, int viewheight)
 
void R_Water_AddWaterPlane (msurface_t *surface, int entno)
 
static void R_Water_ProcessPlanes (int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
static void R_Bloom_StartFrame (void)
 
static void R_Bloom_MakeTexture (void)
 
static qbool R_BlendView_IsTrivial (int viewwidth, int viewheight, int width, int height)
 
static void R_MotionBlurView (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
static void R_BlendView (rtexture_t *viewcolortexture, int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height)
 
void R_UpdateFog (void)
 
void R_UpdateVariables (void)
 
void R_SelectScene (r_refdef_scene_type_t scenetype)
 
r_refdef_scene_tR_GetScenePointer (r_refdef_scene_type_t scenetype)
 
static int R_SortEntities_Compare (const void *ap, const void *bp)
 
static void R_SortEntities (void)
 
void V_MakeViewIsometric (void)
 
void R_RenderView (int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height)
 
void R_RenderWaterPlanes (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
static void R_DrawLocs (void)
 
static void R_DrawEntityBBoxes (prvm_prog_t *prog)
 
static void R_DrawModelDecals (void)
 
void R_RenderScene (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
static void R_DrawBBoxMesh (vec3_t mins, vec3_t maxs, float cr, float cg, float cb, float ca)
 
static void R_DrawEntityBBoxes_Callback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
static void R_DrawNoModel_TransparentCallback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
void R_CalcBeam_Vertex3f (float *vert, const float *org1, const float *org2, float width)
 
void R_CalcSprite_Vertex3f (float *vertex3f, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2)
 
static int R_Mesh_AddVertex (rmesh_t *mesh, float x, float y, float z)
 
void R_Mesh_AddPolygon3f (rmesh_t *mesh, int numvertices, float *vertex3f)
 
static void R_Mesh_AddPolygon3d (rmesh_t *mesh, int numvertices, double *vertex3d)
 
void R_Mesh_AddBrushMeshFromPlanes (rmesh_t *mesh, int numplanes, mplane_t *planes)
 
static qbool R_TestQ3WaveFunc (q3wavefunc_t func, const float *parms)
 
static float R_EvaluateQ3WaveFunc (q3wavefunc_t func, const float *parms)
 
static void R_tcMod_ApplyToMatrix (matrix4x4_t *texmatrix, q3shaderinfo_layer_tcmod_t *tcmod, int currentmaterialflags)
 
static void R_LoadQWSkin (r_qwskincache_t *cache, const char *skinname)
 
texture_tR_GetCurrentTexture (texture_t *t)
 
void RSurf_ActiveModelEntity (const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass)
 
void RSurf_ActiveCustomEntity (const matrix4x4_t *matrix, const matrix4x4_t *inversematrix, int entflags, double shadertime, float r, float g, float b, float a, int numvertices, const float *vertex3f, const float *texcoord2f, const float *normal3f, const float *svector3f, const float *tvector3f, const float *color4f, int numtriangles, const int *element3i, const unsigned short *element3s, qbool wantnormals, qbool wanttangents)
 
float RSurf_FogPoint (const float *v)
 
float RSurf_FogVertex (const float *v)
 
void RSurf_UploadBuffersForBatch (void)
 
static void RSurf_RenumberElements (const int *inelement3i, int *outelement3i, int numelements, int adjust)
 
void RSurf_PrepareVerticesForBatch (int batchneed, int texturenumsurfaces, const msurface_t **texturesurfacelist)
 
void RSurf_DrawBatch (void)
 
static int RSurf_FindWaterPlaneForSurface (const msurface_t *surface)
 
void RSurf_SetupDepthAndCulling (bool ui)
 
static void R_DrawTextureSurfaceList_Sky (int texturenumsurfaces, const msurface_t **texturesurfacelist)
 
static void R_DrawTextureSurfaceList_GL20 (int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
 
static void R_DrawTextureSurfaceList_ShowSurfaces (int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth)
 
static void R_DrawModelTextureSurfaceList (int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
 
static void R_DrawSurface_TransparentCallback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
static void R_ProcessTransparentTextureSurfaceList (int texturenumsurfaces, const msurface_t **texturesurfacelist)
 
static void R_DrawTextureSurfaceList_DepthOnly (int texturenumsurfaces, const msurface_t **texturesurfacelist)
 
static void R_ProcessModelTextureSurfaceList (int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
 
static void R_QueueModelSurfaceList (entity_render_t *ent, int numsurfaces, const msurface_t **surfacelist, int flagsmask, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
 
static void R_DrawLoc_Callback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
void R_DecalSystem_Reset (decalsystem_t *decalsystem)
 
static void R_DecalSystem_SpawnTriangle (decalsystem_t *decalsystem, const float *v0, const float *v1, const float *v2, const float *t0, const float *t1, const float *t2, const float *c0, const float *c1, const float *c2, int triangleindex, int surfaceindex, unsigned int decalsequence)
 
static void R_DecalSystem_SplatTriangle (decalsystem_t *decalsystem, float r, float g, float b, float a, float s1, float t1, float s2, float t2, unsigned int decalsequence, qbool dynamic, float(*planes)[4], matrix4x4_t *projection, int triangleindex, int surfaceindex)
 
static void R_DecalSystem_SplatEntity (entity_render_t *ent, const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize, unsigned int decalsequence)
 
static void R_DecalSystem_ApplySplatEntities (const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize, unsigned int decalsequence)
 
void R_DecalSystem_SplatEntities (const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize)
 
static void R_DecalSystem_ApplySplatEntitiesQueue (void)
 
static void R_DrawModelDecals_FadeEntity (entity_render_t *ent)
 
static void R_DrawModelDecals_Entity (entity_render_t *ent)
 
static void R_DrawDebugModel (void)
 
void R_DrawModelSurfaces (entity_render_t *ent, qbool skysurfaces, qbool writedepth, qbool depthonly, qbool debug, qbool prepass, qbool ui)
 
void R_DebugLine (vec3_t start, vec3_t end)
 
void R_DrawCustomSurface (skinframe_t *skinframe, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
 
void R_DrawCustomSurface_Texture (texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
 

Variables

mempool_tr_main_mempool
 
rtexturepool_tr_main_texturepool
 
int r_textureframe = 0
 used only by R_GetCurrentTexture, incremented per view and per UI render
 
static qbool r_loadnormalmap
 
static qbool r_loadgloss
 
qbool r_loadfog
 
static qbool r_loaddds
 
static qbool r_savedds
 
static qbool r_gpuskeletal
 
r_refdef_t r_refdef
 
cvar_t r_motionblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur", "0", "screen motionblur - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"}
 
cvar_t r_damageblur = {CF_CLIENT | CF_ARCHIVE, "r_damageblur", "0", "screen motionblur based on damage - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"}
 
cvar_t r_motionblur_averaging = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_averaging", "0.1", "sliding average reaction time for velocity (higher = slower adaption to change)"}
 
cvar_t r_motionblur_randomize = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_randomize", "0.1", "randomizing coefficient to workaround ghosting"}
 
cvar_t r_motionblur_minblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_minblur", "0.5", "factor of blur to apply at all times (always have this amount of blur no matter what the other factors are)"}
 
cvar_t r_motionblur_maxblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_maxblur", "0.9", "maxmimum amount of blur"}
 
cvar_t r_motionblur_velocityfactor = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor", "1", "factoring in of player velocity to the blur equation - the faster the player moves around the map, the more blur they get"}
 
cvar_t r_motionblur_velocityfactor_minspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_minspeed", "400", "lower value of velocity when it starts to factor into blur equation"}
 
cvar_t r_motionblur_velocityfactor_maxspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_maxspeed", "800", "upper value of velocity when it reaches the peak factor into blur equation"}
 
cvar_t r_motionblur_mousefactor = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor", "2", "factoring in of mouse acceleration to the blur equation - the faster the player turns their mouse, the more blur they get"}
 
cvar_t r_motionblur_mousefactor_minspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_minspeed", "0", "lower value of mouse acceleration when it starts to factor into blur equation"}
 
cvar_t r_motionblur_mousefactor_maxspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_maxspeed", "50", "upper value of mouse acceleration when it reaches the peak factor into blur equation"}
 
cvar_t r_depthfirst = {CF_CLIENT | CF_ARCHIVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"}
 
cvar_t r_useinfinitefarclip = {CF_CLIENT | CF_ARCHIVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"}
 
cvar_t r_farclip_base = {CF_CLIENT, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"}
 
cvar_t r_farclip_world = {CF_CLIENT, "r_farclip_world", "2", "adds map size to farclip multiplied by this value"}
 
cvar_t r_nearclip = {CF_CLIENT, "r_nearclip", "1", "distance from camera of nearclip plane" }
 
cvar_t r_deformvertexes = {CF_CLIENT, "r_deformvertexes", "1", "allows use of deformvertexes in shader files (can be turned off to check performance impact)"}
 
cvar_t r_transparent = {CF_CLIENT, "r_transparent", "1", "allows use of transparent surfaces (can be turned off to check performance impact)"}
 
cvar_t r_transparent_alphatocoverage = {CF_CLIENT, "r_transparent_alphatocoverage", "1", "enables GL_ALPHA_TO_COVERAGE antialiasing technique on alphablend and alphatest surfaces when using vid_samples 2 or higher"}
 
cvar_t r_transparent_sortsurfacesbynearest = {CF_CLIENT, "r_transparent_sortsurfacesbynearest", "1", "sort entity and world surfaces by nearest point on bounding box instead of using the center of the bounding box, usually reduces sorting artifacts"}
 
cvar_t r_transparent_useplanardistance = {CF_CLIENT, "r_transparent_useplanardistance", "0", "sort transparent meshes by distance from view plane rather than spherical distance to the chosen point"}
 
cvar_t r_showoverdraw = {CF_CLIENT, "r_showoverdraw", "0", "shows overlapping geometry"}
 
cvar_t r_showbboxes = {CF_CLIENT, "r_showbboxes", "0", "shows bounding boxes of server entities, value controls opacity scaling (1 = 10%, 10 = 100%)"}
 
cvar_t r_showbboxes_client = {CF_CLIENT, "r_showbboxes_client", "0", "shows bounding boxes of clientside qc entities, value controls opacity scaling (1 = 10%, 10 = 100%)"}
 
cvar_t r_showsurfaces = {CF_CLIENT, "r_showsurfaces", "0", "1 shows surfaces as different colors, or a value of 3 shows an approximation to vertex or object color (for a very approximate view of the game)"}
 
cvar_t r_showtris = {CF_CLIENT, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"}
 
cvar_t r_shownormals = {CF_CLIENT, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"}
 
cvar_t r_showlighting = {CF_CLIENT, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"}
 
cvar_t r_showcollisionbrushes = {CF_CLIENT, "r_showcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"}
 
cvar_t r_showcollisionbrushes_polygonfactor = {CF_CLIENT, "r_showcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"}
 
cvar_t r_showcollisionbrushes_polygonoffset = {CF_CLIENT, "r_showcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"}
 
cvar_t r_showdisabledepthtest = {CF_CLIENT, "r_showdisabledepthtest", "0", "disables depth testing on r_show* cvars, allowing you to see what hidden geometry the graphics card is processing"}
 
cvar_t r_showspriteedges = {CF_CLIENT, "r_showspriteedges", "0", "renders a debug outline to show the polygon shape of each sprite frame rendered (may be 2 or more in case of interpolated animations), for debugging rendering bugs with specific view types"}
 
cvar_t r_showparticleedges = {CF_CLIENT, "r_showparticleedges", "0", "renders a debug outline to show the polygon shape of each particle, for debugging rendering bugs with specific view types"}
 
cvar_t r_drawportals = {CF_CLIENT, "r_drawportals", "0", "shows portals (separating polygons) in world interior in quake1 maps"}
 
cvar_t r_drawentities = {CF_CLIENT, "r_drawentities","1", "draw entities (doors, players, projectiles, etc)"}
 
cvar_t r_draw2d = {CF_CLIENT, "r_draw2d","1", "draw 2D stuff (dangerous to turn off)"}
 
cvar_t r_drawworld = {CF_CLIENT, "r_drawworld","1", "draw world (most static stuff)"}
 
cvar_t r_drawviewmodel = {CF_CLIENT, "r_drawviewmodel","1", "draw your weapon model"}
 
cvar_t r_drawexteriormodel = {CF_CLIENT, "r_drawexteriormodel","1", "draw your player model (e.g. in chase cam, reflections)"}
 
cvar_t r_cullentities_trace = {CF_CLIENT, "r_cullentities_trace", "1", "probabistically cull invisible entities"}
 
cvar_t r_cullentities_trace_entityocclusion = {CF_CLIENT, "r_cullentities_trace_entityocclusion", "1", "check for occluding entities such as doors, not just world hull"}
 
cvar_t r_cullentities_trace_samples = {CF_CLIENT, "r_cullentities_trace_samples", "2", "number of samples to test for entity culling (in addition to center sample)"}
 
cvar_t r_cullentities_trace_tempentitysamples = {CF_CLIENT, "r_cullentities_trace_tempentitysamples", "-1", "number of samples to test for entity culling of temp entities (including all CSQC entities), -1 disables trace culling on these entities to prevent flicker (pvs still applies)"}
 
cvar_t r_cullentities_trace_enlarge = {CF_CLIENT, "r_cullentities_trace_enlarge", "0", "box enlargement for entity culling"}
 
cvar_t r_cullentities_trace_expand = {CF_CLIENT, "r_cullentities_trace_expand", "0", "box expanded by this many units for entity culling"}
 
cvar_t r_cullentities_trace_pad = {CF_CLIENT, "r_cullentities_trace_pad", "8", "accept traces that hit within this many units of the box"}
 
cvar_t r_cullentities_trace_delay = {CF_CLIENT, "r_cullentities_trace_delay", "1", "number of seconds until the entity gets actually culled"}
 
cvar_t r_cullentities_trace_eyejitter = {CF_CLIENT, "r_cullentities_trace_eyejitter", "16", "randomly offset rays from the eye by this much to reduce the odds of flickering"}
 
cvar_t r_sortentities = {CF_CLIENT, "r_sortentities", "0", "sort entities before drawing (might be faster)"}
 
cvar_t r_speeds = {CF_CLIENT, "r_speeds","0", "displays rendering statistics and per-subsystem timings"}
 
cvar_t r_fullbright = {CF_CLIENT, "r_fullbright","0", "makes map very bright and renders faster"}
 
cvar_t r_fullbright_directed = {CF_CLIENT, "r_fullbright_directed", "0", "render fullbright things (unlit worldmodel and EF_FULLBRIGHT entities, but not fullbright shaders) using a constant light direction instead to add more depth while keeping uniform brightness"}
 
cvar_t r_fullbright_directed_ambient = {CF_CLIENT, "r_fullbright_directed_ambient", "0.5", "ambient light multiplier for directed fullbright"}
 
cvar_t r_fullbright_directed_diffuse = {CF_CLIENT, "r_fullbright_directed_diffuse", "0.75", "diffuse light multiplier for directed fullbright"}
 
cvar_t r_fullbright_directed_pitch = {CF_CLIENT, "r_fullbright_directed_pitch", "20", "constant pitch direction ('height') of the fake light source to use for fullbright"}
 
cvar_t r_fullbright_directed_pitch_relative = {CF_CLIENT, "r_fullbright_directed_pitch_relative", "0", "whether r_fullbright_directed_pitch is interpreted as absolute (0) or relative (1) pitch"}
 
cvar_t r_wateralpha = {CF_CLIENT | CF_ARCHIVE, "r_wateralpha","1", "opacity of water polygons"}
 
cvar_t r_dynamic = {CF_CLIENT | CF_ARCHIVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"}
 
cvar_t r_fullbrights = {CF_CLIENT | CF_ARCHIVE, "r_fullbrights", "1", "enables glowing pixels in quake textures (changes need r_restart to take effect)"}
 
cvar_t r_shadows = {CF_CLIENT | CF_ARCHIVE, "r_shadows", "0", "casts fake stencil shadows from models onto the world (rtlights are unaffected by this); when set to 2, always cast the shadows in the direction set by r_shadows_throwdirection, otherwise use the model lighting."}
 
cvar_t r_shadows_darken = {CF_CLIENT | CF_ARCHIVE, "r_shadows_darken", "0.5", "how much shadowed areas will be darkened"}
 
cvar_t r_shadows_throwdistance = {CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdistance", "500", "how far to cast shadows from models"}
 
cvar_t r_shadows_throwdirection = {CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdirection", "0 0 -1", "override throwing direction for r_shadows 2"}
 
cvar_t r_shadows_drawafterrtlighting = {CF_CLIENT | CF_ARCHIVE, "r_shadows_drawafterrtlighting", "0", "draw fake shadows AFTER realtime lightning is drawn. May be useful for simulating fast sunlight on large outdoor maps with only one noshadow rtlight. The price is less realistic appearance of dynamic light shadows."}
 
cvar_t r_shadows_castfrombmodels = {CF_CLIENT | CF_ARCHIVE, "r_shadows_castfrombmodels", "0", "do cast shadows from bmodels"}
 
cvar_t r_shadows_focus = {CF_CLIENT | CF_ARCHIVE, "r_shadows_focus", "0 0 0", "offset the shadowed area focus"}
 
cvar_t r_shadows_shadowmapscale = {CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapscale", "0.25", "higher values increase shadowmap quality at a cost of area covered (multiply global shadowmap precision) for fake shadows. Needs shadowmapping ON."}
 
cvar_t r_shadows_shadowmapbias = {CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapbias", "-1", "sets shadowmap bias for fake shadows. -1 sets the value of r_shadow_shadowmapping_bias. Needs shadowmapping ON."}
 
cvar_t r_q1bsp_skymasking = {CF_CLIENT, "r_q1bsp_skymasking", "1", "allows sky polygons in quake1 maps to obscure other geometry"}
 
cvar_t r_polygonoffset_submodel_factor = {CF_CLIENT, "r_polygonoffset_submodel_factor", "0", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"}
 
cvar_t r_polygonoffset_submodel_offset = {CF_CLIENT, "r_polygonoffset_submodel_offset", "14", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"}
 
cvar_t r_polygonoffset_decals_factor = {CF_CLIENT, "r_polygonoffset_decals_factor", "0", "biases depth values of decals to prevent z-fighting artifacts"}
 
cvar_t r_polygonoffset_decals_offset = {CF_CLIENT, "r_polygonoffset_decals_offset", "-14", "biases depth values of decals to prevent z-fighting artifacts"}
 
cvar_t r_fog_exp2 = {CF_CLIENT, "r_fog_exp2", "0", "uses GL_EXP2 fog (as in Nehahra) rather than realistic GL_EXP fog"}
 
cvar_t r_fog_clear = {CF_CLIENT, "r_fog_clear", "1", "clears renderbuffer with fog color before render starts"}
 
cvar_t r_drawfog = {CF_CLIENT | CF_ARCHIVE, "r_drawfog", "1", "allows one to disable fog rendering"}
 
cvar_t r_transparentdepthmasking = {CF_CLIENT | CF_ARCHIVE, "r_transparentdepthmasking", "0", "enables depth writes on transparent meshes whose materially is normally opaque, this prevents seeing the inside of a transparent mesh"}
 
cvar_t r_transparent_sortmindist = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmindist", "0", "lower distance limit for transparent sorting"}
 
cvar_t r_transparent_sortmaxdist = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmaxdist", "32768", "upper distance limit for transparent sorting"}
 
cvar_t r_transparent_sortarraysize = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortarraysize", "4096", "number of distance-sorting layers"}
 
cvar_t r_celshading = {CF_CLIENT | CF_ARCHIVE, "r_celshading", "0", "cartoon-style light shading (OpenGL 2.x only)"}
 
cvar_t r_celoutlines = {CF_CLIENT | CF_ARCHIVE, "r_celoutlines", "0", "cartoon-style outlines (requires r_shadow_deferred)"}
 
cvar_t gl_fogenable = {CF_CLIENT, "gl_fogenable", "0", "nehahra fog enable (for Nehahra compatibility only)"}
 
cvar_t gl_fogdensity = {CF_CLIENT, "gl_fogdensity", "0.25", "nehahra fog density (recommend values below 0.1) (for Nehahra compatibility only)"}
 
cvar_t gl_fogred = {CF_CLIENT, "gl_fogred","0.3", "nehahra fog color red value (for Nehahra compatibility only)"}
 
cvar_t gl_foggreen = {CF_CLIENT, "gl_foggreen","0.3", "nehahra fog color green value (for Nehahra compatibility only)"}
 
cvar_t gl_fogblue = {CF_CLIENT, "gl_fogblue","0.3", "nehahra fog color blue value (for Nehahra compatibility only)"}
 
cvar_t gl_fogstart = {CF_CLIENT, "gl_fogstart", "0", "nehahra fog start distance (for Nehahra compatibility only)"}
 
cvar_t gl_fogend = {CF_CLIENT, "gl_fogend","0", "nehahra fog end distance (for Nehahra compatibility only)"}
 
cvar_t gl_skyclip = {CF_CLIENT, "gl_skyclip", "4608", "nehahra farclip distance - the real fog end (for Nehahra compatibility only)"}
 
cvar_t r_texture_dds_load = {CF_CLIENT | CF_ARCHIVE, "r_texture_dds_load", "0", "load compressed dds/filename.dds texture instead of filename.tga, if the file exists (requires driver support)"}
 
cvar_t r_texture_dds_save = {CF_CLIENT | CF_ARCHIVE, "r_texture_dds_save", "0", "save compressed dds/filename.dds texture when filename.tga is loaded, so that it can be loaded instead next time"}
 
cvar_t r_usedepthtextures = {CF_CLIENT | CF_ARCHIVE, "r_usedepthtextures", "1", "use depth texture instead of depth renderbuffer where possible, uses less video memory but may render slower (or faster) depending on hardware"}
 
cvar_t r_viewfbo = {CF_CLIENT | CF_ARCHIVE, "r_viewfbo", "0", "enables use of an 8bit (1) or 16bit (2) or 32bit (3) per component float framebuffer render, which may be at a different resolution than the video mode; the default setting of 0 uses a framebuffer render when required, and renders directly to the screen otherwise"}
 
cvar_t r_rendertarget_debug = {CF_CLIENT, "r_rendertarget_debug", "-1", "replaces the view with the contents of the specified render target (by number - note that these can fluctuate depending on scene)"}
 
cvar_t r_viewscale = {CF_CLIENT | CF_ARCHIVE, "r_viewscale", "1", "scaling factor for resolution of the fbo rendering method, must be > 0, can be above 1 for a costly antialiasing behavior, typical values are 0.5 for 1/4th as many pixels rendered, or 1 for normal rendering"}
 
cvar_t r_viewscale_fpsscaling = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling", "0", "change resolution based on framerate"}
 
cvar_t r_viewscale_fpsscaling_min = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_min", "0.0625", "worst acceptable quality"}
 
cvar_t r_viewscale_fpsscaling_multiply = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_multiply", "5", "adjust quality up or down by the frametime difference from 1.0/target, multiplied by this factor"}
 
cvar_t r_viewscale_fpsscaling_stepsize = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepsize", "0.01", "smallest adjustment to hit the target framerate (this value prevents minute oscillations)"}
 
cvar_t r_viewscale_fpsscaling_stepmax = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepmax", "1.00", "largest adjustment to hit the target framerate (this value prevents wild overshooting of the estimate)"}
 
cvar_t r_viewscale_fpsscaling_target = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_target", "70", "desired framerate"}
 
cvar_t r_glsl_skeletal = {CF_CLIENT | CF_ARCHIVE, "r_glsl_skeletal", "1", "render skeletal models faster using a gpu-skinning technique"}
 
cvar_t r_glsl_deluxemapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"}
 
cvar_t r_glsl_offsetmapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"}
 
cvar_t r_glsl_offsetmapping_steps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_steps", "2", "offset mapping steps (note: too high values may be not supported by your GPU)"}
 
cvar_t r_glsl_offsetmapping_reliefmapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping", "0", "relief mapping effect (higher quality)"}
 
cvar_t r_glsl_offsetmapping_reliefmapping_steps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_steps", "10", "relief mapping steps (note: too high values may be not supported by your GPU)"}
 
cvar_t r_glsl_offsetmapping_reliefmapping_refinesteps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_refinesteps", "5", "relief mapping refine steps (these are a binary search executed as the last step as given by r_glsl_offsetmapping_reliefmapping_steps)"}
 
cvar_t r_glsl_offsetmapping_scale = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_scale", "0.04", "how deep the offset mapping effect is"}
 
cvar_t r_glsl_offsetmapping_lod = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod", "0", "apply distance-based level-of-detail correction to number of offsetmappig steps, effectively making it render faster on large open-area maps"}
 
cvar_t r_glsl_offsetmapping_lod_distance = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod_distance", "32", "first LOD level distance, second level (-50% steps) is 2x of this, third (33%) - 3x etc."}
 
cvar_t r_glsl_postprocess = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess", "0", "use a GLSL postprocessing shader"}
 
cvar_t r_glsl_postprocess_uservec1 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1", "0 0 0 0", "a 4-component vector to pass as uservec1 to the postprocessing shader (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec2 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2", "0 0 0 0", "a 4-component vector to pass as uservec2 to the postprocessing shader (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec3 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3", "0 0 0 0", "a 4-component vector to pass as uservec3 to the postprocessing shader (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec4 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4", "0 0 0 0", "a 4-component vector to pass as uservec4 to the postprocessing shader (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec1_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1_enable", "1", "enables postprocessing uservec1 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec2_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2_enable", "1", "enables postprocessing uservec2 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec3_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3_enable", "1", "enables postprocessing uservec3 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec4_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4_enable", "1", "enables postprocessing uservec4 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}
 
cvar_t r_colorfringe = {CF_CLIENT | CF_ARCHIVE, "r_colorfringe", "0", "Chromatic aberration. Values higher than 0.025 will noticeably distort the image"}
 
cvar_t r_fxaa = {CF_CLIENT | CF_ARCHIVE, "r_fxaa", "0", "fast approximate anti aliasing"}
 
cvar_t r_water = {CF_CLIENT | CF_ARCHIVE, "r_water", "0", "whether to use reflections and refraction on water surfaces (note: r_wateralpha must be set below 1)"}
 
cvar_t r_water_cameraentitiesonly = {CF_CLIENT | CF_ARCHIVE, "r_water_cameraentitiesonly", "0", "whether to only show QC-defined reflections/refractions (typically used for camera- or portal-like effects)"}
 
cvar_t r_water_clippingplanebias = {CF_CLIENT | CF_ARCHIVE, "r_water_clippingplanebias", "1", "a rather technical setting which avoids black pixels around water edges"}
 
cvar_t r_water_resolutionmultiplier = {CF_CLIENT | CF_ARCHIVE, "r_water_resolutionmultiplier", "0.5", "multiplier for screen resolution when rendering refracted/reflected scenes, 1 is full quality, lower values are faster"}
 
cvar_t r_water_refractdistort = {CF_CLIENT | CF_ARCHIVE, "r_water_refractdistort", "0.01", "how much water refractions shimmer"}
 
cvar_t r_water_reflectdistort = {CF_CLIENT | CF_ARCHIVE, "r_water_reflectdistort", "0.01", "how much water reflections shimmer"}
 
cvar_t r_water_scissormode = {CF_CLIENT, "r_water_scissormode", "3", "scissor (1) or cull (2) or both (3) water renders"}
 
cvar_t r_water_lowquality = {CF_CLIENT, "r_water_lowquality", "0", "special option to accelerate water rendering: 1 disables all dynamic lights, 2 disables particles too"}
 
cvar_t r_water_hideplayer = {CF_CLIENT | CF_ARCHIVE, "r_water_hideplayer", "0", "if set to 1 then player will be hidden in refraction views, if set to 2 then player will also be hidden in reflection views, player is always visible in camera views"}
 
cvar_t r_lerpsprites = {CF_CLIENT | CF_ARCHIVE, "r_lerpsprites", "0", "enables animation smoothing on sprites"}
 
cvar_t r_lerpmodels = {CF_CLIENT | CF_ARCHIVE, "r_lerpmodels", "1", "enables animation smoothing on models"}
 
cvar_t r_nolerp_list = {CF_CLIENT | CF_ARCHIVE, "r_nolerp_list", "progs/v_nail.mdl,progs/v_nail2.mdl,progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl", "comma separated list of models that will not have their animations smoothed"}
 
cvar_t r_lerplightstyles = {CF_CLIENT | CF_ARCHIVE, "r_lerplightstyles", "0", "enable animation smoothing on flickering lights"}
 
cvar_t r_waterscroll = {CF_CLIENT | CF_ARCHIVE, "r_waterscroll", "1", "makes water scroll around, value controls how much"}
 
cvar_t r_bloom = {CF_CLIENT | CF_ARCHIVE, "r_bloom", "0", "enables bloom effect (makes bright pixels affect neighboring pixels)"}
 
cvar_t r_bloom_colorscale = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorscale", "1", "how bright the glow is"}
 
cvar_t r_bloom_brighten = {CF_CLIENT | CF_ARCHIVE, "r_bloom_brighten", "1", "how bright the glow is, after subtract/power"}
 
cvar_t r_bloom_blur = {CF_CLIENT | CF_ARCHIVE, "r_bloom_blur", "4", "how large the glow is"}
 
cvar_t r_bloom_resolution = {CF_CLIENT | CF_ARCHIVE, "r_bloom_resolution", "320", "what resolution to perform the bloom effect at (independent of screen resolution)"}
 
cvar_t r_bloom_colorexponent = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorexponent", "1", "how exaggerated the glow is"}
 
cvar_t r_bloom_colorsubtract = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorsubtract", "0.1", "reduces bloom colors by a certain amount"}
 
cvar_t r_bloom_scenebrightness = {CF_CLIENT | CF_ARCHIVE, "r_bloom_scenebrightness", "1", "global rendering brightness when bloom is enabled"}
 
cvar_t r_hdr_scenebrightness = {CF_CLIENT | CF_ARCHIVE, "r_hdr_scenebrightness", "1", "global rendering brightness"}
 
cvar_t r_hdr_glowintensity = {CF_CLIENT | CF_ARCHIVE, "r_hdr_glowintensity", "1", "how bright light emitting textures should appear"}
 
cvar_t r_hdr_irisadaptation = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation", "0", "adjust scene brightness according to light intensity at player location"}
 
cvar_t r_hdr_irisadaptation_multiplier = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_multiplier", "2", "brightness at which value will be 1.0"}
 
cvar_t r_hdr_irisadaptation_minvalue = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_minvalue", "0.5", "minimum value that can result from multiplier / brightness"}
 
cvar_t r_hdr_irisadaptation_maxvalue = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_maxvalue", "4", "maximum value that can result from multiplier / brightness"}
 
cvar_t r_hdr_irisadaptation_value = {CF_CLIENT, "r_hdr_irisadaptation_value", "1", "current value as scenebrightness multiplier, changes continuously when irisadaptation is active"}
 
cvar_t r_hdr_irisadaptation_fade_up = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_up", "0.1", "fade rate at which value adjusts to darkness"}
 
cvar_t r_hdr_irisadaptation_fade_down = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_down", "0.5", "fade rate at which value adjusts to brightness"}
 
cvar_t r_hdr_irisadaptation_radius = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_radius", "15", "lighting within this many units of the eye is averaged"}
 
cvar_t r_smoothnormals_areaweighting = {CF_CLIENT, "r_smoothnormals_areaweighting", "1", "uses significantly faster (and supposedly higher quality) area-weighted vertex normals and tangent vectors rather than summing normalized triangle normals and tangents"}
 
cvar_t developer_texturelogging = {CF_CLIENT, "developer_texturelogging", "0", "produces a textures.log file containing names of skins and map textures the engine tried to load"}
 
cvar_t gl_lightmaps = {CF_CLIENT, "gl_lightmaps", "0", "draws only lightmaps, no texture (for level designers), a value of 2 keeps normalmap shading"}
 
cvar_t r_test = {CF_CLIENT, "r_test", "0", "internal development use only, leave it alone (usually does nothing anyway)"}
 
cvar_t r_batch_multidraw = {CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw", "1", "issue multiple glDrawElements calls when rendering a batch of surfaces with the same texture (otherwise the index data is copied to make it one draw)"}
 
cvar_t r_batch_multidraw_mintriangles = {CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw_mintriangles", "0", "minimum number of triangles to activate multidraw path (copying small groups of triangles may be faster)"}
 
cvar_t r_batch_debugdynamicvertexpath = {CF_CLIENT | CF_ARCHIVE, "r_batch_debugdynamicvertexpath", "0", "force the dynamic batching code path for debugging purposes"}
 
cvar_t r_batch_dynamicbuffer = {CF_CLIENT | CF_ARCHIVE, "r_batch_dynamicbuffer", "0", "use vertex/index buffers for drawing dynamic and copytriangles batches"}
 
cvar_t r_glsl_saturation = {CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation", "1", "saturation multiplier (only working in glsl!)"}
 
cvar_t r_glsl_saturation_redcompensate = {CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation_redcompensate", "0", "a 'vampire sight' addition to desaturation effect, does compensation for red color, r_glsl_restart is required"}
 
cvar_t r_glsl_vertextextureblend_usebothalphas = {CF_CLIENT | CF_ARCHIVE, "r_glsl_vertextextureblend_usebothalphas", "0", "use both alpha layers on vertex blended surfaces, each alpha layer sets amount of 'blend leak' on another layer, requires mod_q3shader_force_terrain_alphaflag on."}
 
cvar_t r_framedatasize = {CF_CLIENT | CF_ARCHIVE, "r_framedatasize", "0.5", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"}
 
cvar_t r_buffermegs [R_BUFFERDATA_COUNT]
 
cvar_t r_q1bsp_lightmap_updates_enabled = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"}
 
cvar_t r_q1bsp_lightmap_updates_combine = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_combine", "2", "combine lightmap texture updates to make fewer glTexSubImage2D calls, modes: 0 = immediately upload lightmaps (may be thousands of small 3x3 updates), 1 = combine to one call, 2 = combine to one full texture update (glTexImage2D) which tells the driver it does not need to lock the resource (faster on most drivers)"}
 
cvar_t r_q1bsp_lightmap_updates_hidden_surfaces = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_hidden_surfaces", "0", "update lightmaps on surfaces that are not visible, so that updates only occur on frames where lightstyles changed value (animation or light switches), only makes sense with combine = 2"}
 
cvar_t v_glslgamma_2d
 
qbool v_flipped_state
 
r_framebufferstate_t r_fb
 
svbsp_t r_svbsp
 shadow volume bsp struct with automatically growing nodes buffer
 
int r_uniformbufferalignment = 32
 
rtexture_tr_texture_blanknormalmap
 
rtexture_tr_texture_white
 
rtexture_tr_texture_grey128
 
rtexture_tr_texture_black
 
rtexture_tr_texture_notexture
 
rtexture_tr_texture_whitecube
 
rtexture_tr_texture_normalizationcube
 
rtexture_tr_texture_fogattenuation
 
rtexture_tr_texture_fogheighttexture
 
rtexture_tr_texture_gammaramps
 
unsigned int r_texture_gammaramps_serial
 
rtexture_tr_texture_reflectcube
 
int r_texture_numcubemaps
 
cubemapinfo_tr_texture_cubemaps [MAX_CUBEMAPS]
 
unsigned int r_queries [MAX_OCCLUSION_QUERIES]
 
unsigned int r_numqueries
 
unsigned int r_maxqueries
 
static r_qwskincache_tr_qwskincache
 
static int r_qwskincache_size
 
const float r_screenvertex3f [12]
 vertex coordinates for a quad that covers the screen exactly
 
static const charbuiltinshaderstrings []
 
shaderpermutationinfo_t shaderpermutationinfo [SHADERPERMUTATION_COUNT]
 
shadermodeinfo_t shadermodeinfo [SHADERLANGUAGE_COUNT][SHADERMODE_COUNT]
 
static const charshaderstaticparmstrings_list [SHADERSTATICPARMS_COUNT]
 
static int shaderstaticparms_count = 0
 
static unsigned int r_compileshader_staticparms [(SHADERSTATICPARMS_COUNT+0x1F) > > 5] = {0}
 
qbool r_shadow_shadowmapsampler
 
int r_shadow_shadowmappcf
 
r_glsl_permutation_tr_glsl_permutationhash [SHADERMODE_COUNT][SHADERPERMUTATION_HASHSIZE]
 information about each possible shader permutation
 
r_glsl_permutation_tr_glsl_permutation
 currently selected permutation
 
memexpandablearray_t r_glsl_permutationarray
 storage for permutations linked in the hash table
 
r_skinframe_t r_skinframe
 
cvar_t gl_picmip
 
static suffixinfo_t suffix [3][6]
 
static int componentorder [4] = {0, 1, 2, 3}
 
rtexture_tloadingscreentexture
 
unsigned int r_shadow_occlusion_buf
 
static r_framedata_mem_tr_framedata_mem
 
static int r_bufferdata_cycle = 0
 
static r_bufferdata_buffer_tr_bufferdata_buffer [R_BUFFERDATA_CYCLE][R_BUFFERDATA_COUNT]
 
static float irisvecs [7][3] = {{0, 0, 0}, {-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}}
 
cvar_t r_lockvisibility
 
cvar_t r_lockpvs
 
float viewscalefpsadjusted = 1.0f
 
cvar_t r_drawparticles
 
cvar_t r_drawdecals
 
matrix4x4_t r_waterscrollmatrix
 
static r_refdef_scene_type_t r_currentscenetype = RST_CLIENT
 
static r_refdef_scene_t r_scenes_store [RST_COUNT]
 
cvar_t r_shadow_bouncegrid
 
cvar_t v_isometric
 
cvar_t cl_locs_show
 
qbool r_shadow_usingdeferredprepass
 
int r_shadow_shadowmapatlas_modelshadows_size
 
static const unsigned short bboxelements [36]
 
static const float bboxedges [BBOXEDGES][6]
 
static const int nomodelelement3i [24]
 
static const unsigned short nomodelelement3s [24]
 
static const float nomodelvertex3f [6 *3]
 
static const float nomodelcolor4f [6 *4]
 
rsurfacestate_t rsurface
 
static const int quadedges [6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}}
 
rtexture_tr_shadow_prepasslightingdiffusetexture
 
rtexture_tr_shadow_prepasslightingspeculartexture
 
float locboxvertex3f [6 *4 *3]
 
unsigned short locboxelements [6 *2 *3]
 
cvar_t cl_decals_bias
 
cvar_t cl_decals_models
 
cvar_t cl_decals_newsystem_intensitymultiplier
 
int r_decalsystem_numqueued = 0
 
r_decalsystem_splatqueue_t r_decalsystem_queue [MAX_DECALSYSTEM_QUEUE]
 
cvar_t cl_decals_max
 
skinframe_tdecalskinframe
 
int r_maxsurfacelist = 0
 
const msurface_t ** r_surfacelist = NULL
 

Macro Definition Documentation

◆ BBOXEDGES

#define BBOXEDGES   13

Definition at line 6048 of file gl_rmain.c.

◆ BLENDFUNC_ALLOWS_ANYFOG

Definition at line 1520 of file gl_rmain.c.

◆ BLENDFUNC_ALLOWS_COLORMOD

#define BLENDFUNC_ALLOWS_COLORMOD   1

Definition at line 1516 of file gl_rmain.c.

◆ BLENDFUNC_ALLOWS_FOG

#define BLENDFUNC_ALLOWS_FOG   2

Definition at line 1517 of file gl_rmain.c.

◆ BLENDFUNC_ALLOWS_FOG_HACK0

#define BLENDFUNC_ALLOWS_FOG_HACK0   4

Definition at line 1518 of file gl_rmain.c.

◆ BLENDFUNC_ALLOWS_FOG_HACKALPHA

#define BLENDFUNC_ALLOWS_FOG_HACKALPHA   8

Definition at line 1519 of file gl_rmain.c.

◆ FOGWIDTH

#define FOGWIDTH   256

◆ NORMSIZE

#define NORMSIZE   64

◆ R_BUFFERDATA_CYCLE

#define R_BUFFERDATA_CYCLE   3

Definition at line 3606 of file gl_rmain.c.

◆ R_COMPILESHADER_STATICPARM_EMIT

#define R_COMPILESHADER_STATICPARM_EMIT (   p,
  n 
)
Value:
if(r_compileshader_staticparms[(p) >> 5] & (1 << ((p) & 0x1F))) \
#define n(x, y)
static const char * shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT]
Definition gl_rmain.c:853
static unsigned int r_compileshader_staticparms[(SHADERSTATICPARMS_COUNT+0x1F) > > 5]
Definition gl_rmain.c:856
static int shaderstaticparms_count
Definition gl_rmain.c:854
GLuint index
Definition glquake.h:628

Definition at line 906 of file gl_rmain.c.

◆ R_COMPILESHADER_STATICPARM_ENABLE

#define R_COMPILESHADER_STATICPARM_ENABLE (   p)    r_compileshader_staticparms[(p) >> 5] |= (1 << ((p) & 0x1F))

Definition at line 857 of file gl_rmain.c.

◆ R_MESH_PLANE_DIST_EPSILON

#define R_MESH_PLANE_DIST_EPSILON   (1.0 / 32.0)

Definition at line 6399 of file gl_rmain.c.

◆ R_SKINFRAME_LOAD_AVERAGE_COLORS

#define R_SKINFRAME_LOAD_AVERAGE_COLORS (   cnt,
  getpixel 
)

Definition at line 2278 of file gl_rmain.c.

2279 { \
2280 unsigned long long avgcolor[5], wsum; \
2281 int pix, comp, w; \
2282 avgcolor[0] = 0; \
2283 avgcolor[1] = 0; \
2284 avgcolor[2] = 0; \
2285 avgcolor[3] = 0; \
2286 avgcolor[4] = 0; \
2287 wsum = 0; \
2288 for(pix = 0; pix < cnt; ++pix) \
2289 { \
2290 w = 0; \
2291 for(comp = 0; comp < 3; ++comp) \
2292 w += getpixel; \
2293 if(w) /* ignore perfectly black pixels because that is better for model skins */ \
2294 { \
2295 ++wsum; \
2296 /* comp = 3; -- not needed, comp is always 3 when we get here */ \
2297 w = getpixel; \
2298 for(comp = 0; comp < 3; ++comp) \
2299 avgcolor[comp] += getpixel * w; \
2300 avgcolor[3] += w; \
2301 } \
2302 /* comp = 3; -- not needed, comp is always 3 when we get here */ \
2303 avgcolor[4] += getpixel; \
2304 } \
2305 if(avgcolor[3] == 0) /* no pixels seen? even worse */ \
2306 avgcolor[3] = 1; \
2307 skinframe->avgcolor[0] = avgcolor[2] / (255.0 * avgcolor[3]); \
2308 skinframe->avgcolor[1] = avgcolor[1] / (255.0 * avgcolor[3]); \
2309 skinframe->avgcolor[2] = avgcolor[0] / (255.0 * avgcolor[3]); \
2310 skinframe->avgcolor[3] = avgcolor[4] / (255.0 * cnt); \
2311 }
GLubyte GLubyte GLubyte GLubyte w
Definition glquake.h:781

◆ RAMPWIDTH

#define RAMPWIDTH   256

◆ SHADERPERMUTATION_HASHSIZE

#define SHADERPERMUTATION_HASHSIZE   256

Definition at line 828 of file gl_rmain.c.

◆ SHADERSTATICPARMS_COUNT

#define SHADERSTATICPARMS_COUNT   15

Definition at line 851 of file gl_rmain.c.

◆ SKINFRAME_HASH

#define SKINFRAME_HASH   1024

Definition at line 2156 of file gl_rmain.c.

Enumeration Type Documentation

◆ anonymous enum

Enumerator
SHADERSTATICPARM_SATURATION_REDCOMPENSATE 

red compensation filter for saturation

SHADERSTATICPARM_EXACTSPECULARMATH 

(lightsource or deluxemapping) use exact reflection map for specular effects, as opposed to the usual OpenGL approximation

SHADERSTATICPARM_POSTPROCESS_USERVEC1 

postprocess uservec1 is enabled

SHADERSTATICPARM_POSTPROCESS_USERVEC2 

postprocess uservec2 is enabled

SHADERSTATICPARM_POSTPROCESS_USERVEC3 

postprocess uservec3 is enabled

SHADERSTATICPARM_POSTPROCESS_USERVEC4 

postprocess uservec4 is enabled

SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS 
SHADERSTATICPARM_OFFSETMAPPING_USELOD 

LOD for offsetmapping.

SHADERSTATICPARM_SHADOWMAPPCF_1 

PCF 1.

SHADERSTATICPARM_SHADOWMAPPCF_2 

PCF 2.

SHADERSTATICPARM_SHADOWSAMPLER 

sampler

SHADERSTATICPARM_CELSHADING 

celshading (alternative diffuse and specular math)

SHADERSTATICPARM_CELOUTLINES 

celoutline (depth buffer analysis to produce outlines)

SHADERSTATICPARM_FXAA 

fast approximate anti aliasing

SHADERSTATICPARM_COLORFRINGE 

colorfringe (chromatic aberration)

Definition at line 833 of file gl_rmain.c.

834{
841 SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS = 6, // use both alpha layers while blending materials, allows more advanced microblending
850};
@ SHADERSTATICPARM_POSTPROCESS_USERVEC4
postprocess uservec4 is enabled
Definition gl_rmain.c:840
@ SHADERSTATICPARM_SHADOWSAMPLER
sampler
Definition gl_rmain.c:845
@ SHADERSTATICPARM_EXACTSPECULARMATH
(lightsource or deluxemapping) use exact reflection map for specular effects, as opposed to the usual...
Definition gl_rmain.c:836
@ SHADERSTATICPARM_CELOUTLINES
celoutline (depth buffer analysis to produce outlines)
Definition gl_rmain.c:847
@ SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS
Definition gl_rmain.c:841
@ SHADERSTATICPARM_SHADOWMAPPCF_1
PCF 1.
Definition gl_rmain.c:843
@ SHADERSTATICPARM_CELSHADING
celshading (alternative diffuse and specular math)
Definition gl_rmain.c:846
@ SHADERSTATICPARM_COLORFRINGE
colorfringe (chromatic aberration)
Definition gl_rmain.c:849
@ SHADERSTATICPARM_POSTPROCESS_USERVEC2
postprocess uservec2 is enabled
Definition gl_rmain.c:838
@ SHADERSTATICPARM_OFFSETMAPPING_USELOD
LOD for offsetmapping.
Definition gl_rmain.c:842
@ SHADERSTATICPARM_FXAA
fast approximate anti aliasing
Definition gl_rmain.c:848
@ SHADERSTATICPARM_POSTPROCESS_USERVEC1
postprocess uservec1 is enabled
Definition gl_rmain.c:837
@ SHADERSTATICPARM_SATURATION_REDCOMPENSATE
red compensation filter for saturation
Definition gl_rmain.c:835
@ SHADERSTATICPARM_SHADOWMAPPCF_2
PCF 2.
Definition gl_rmain.c:844
@ SHADERSTATICPARM_POSTPROCESS_USERVEC3
postprocess uservec3 is enabled
Definition gl_rmain.c:839

Function Documentation

◆ _R_CullBox()

static qbool _R_CullBox ( const vec3_t  mins,
const vec3_t  maxs,
int  numplanes,
const mplane_t planes,
int  ignore 
)
static

Definition at line 3453 of file gl_rmain.c.

3454{
3455 int i;
3456 const mplane_t *p;
3457 vec3_t corner;
3458 if (r_trippy.integer)
3459 return false;
3460 for (i = 0;i < numplanes;i++)
3461 {
3462 if(i == ignore)
3463 continue;
3464 p = planes + i;
3465 R_GetCornerOfBox(corner, mins, maxs, p->signbits);
3466 if (DotProduct(p->normal, corner) < p->dist)
3467 return true;
3468 }
3469 return false;
3470}
static void R_GetCornerOfBox(vec3_t out, const vec3_t mins, const vec3_t maxs, int signbits)
Definition gl_rmain.c:3446
#define DotProduct(a, b)
Definition mathlib.h:97
cvar_t r_trippy
Definition model_brush.c:29
int i
vec_t vec3_t[3]
Definition qtypes.h:67
int integer
Definition cvar.h:73
vec3_t normal
Definition model_brush.h:59
vec_t dist
Definition model_brush.h:60
int signbits
Definition model_brush.h:66

Referenced by R_CullBox(), and R_CullFrustum().

◆ FOG_clear()

void FOG_clear ( void  )

Definition at line 349 of file gl_rmain.c.

350{
351 if (gamemode == GAME_NEHAHRA)
352 {
353 Cvar_Set(&cvars_all, "gl_fogenable", "0");
354 Cvar_Set(&cvars_all, "gl_fogdensity", "0.2");
355 Cvar_Set(&cvars_all, "gl_fogred", "0.3");
356 Cvar_Set(&cvars_all, "gl_foggreen", "0.3");
357 Cvar_Set(&cvars_all, "gl_fogblue", "0.3");
358 }
360 r_refdef.fog_red = 0;
362 r_refdef.fog_blue = 0;
365 r_refdef.fog_end = 16384;
366 r_refdef.fog_height = 1<<30;
369}
gamemode_t gamemode
Definition com_game.c:26
@ GAME_NEHAHRA
Definition com_game.h:32
cvar_state_t cvars_all
Definition cvar.c:28
void Cvar_Set(cvar_state_t *cvars, const char *var_name, const char *value)
equivelant to "<name> <variable>" typed at the console
Definition cvar.c:456
r_refdef_t r_refdef
Definition gl_rmain.c:57
char fog_height_texturename[64]
Definition render.h:449
float fog_start
Definition render.h:441
float fog_density
Definition render.h:436
float fog_height
Definition render.h:443
float fog_green
Definition render.h:438
float fog_alpha
Definition render.h:440
float fog_fadedepth
Definition render.h:444
float fog_end
Definition render.h:442
float fog_blue
Definition render.h:439
float fog_red
Definition render.h:437

Referenced by CL_Fog_f(), CL_Fog_HeightTexture_f(), and CL_ParseEntityLump().

◆ GL_Main_Init()

void GL_Main_Init ( void  )

Definition at line 3228 of file gl_rmain.c.

3229{
3230 int i;
3231 r_main_mempool = Mem_AllocPool("Renderer", 0, NULL);
3233
3234 Cmd_AddCommand(CF_CLIENT, "r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
3235 Cmd_AddCommand(CF_CLIENT, "r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
3236 // FIXME: the client should set up r_refdef.fog stuff including the fogmasktable
3237 if (gamemode == GAME_NEHAHRA)
3238 {
3247 }
3363
3373
3410 for (i = 0;i < R_BUFFERDATA_COUNT;i++)
3417 Cvar_SetValue(&cvars_all, "r_fullbrights", 0);
3418#ifdef DP_MOBILETOUCH
3419 // GLES devices have terrible depth precision in general, so...
3424#endif
3426}
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1754
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
@ GAME_TENEBRAE
Definition com_game.h:41
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
void Cvar_SetValue(cvar_state_t *cvars, const char *var_name, float value)
expands value to a string and calls Cvar_Set
Definition cvar.c:484
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
cvar_t r_shadows_castfrombmodels
Definition gl_rmain.c:128
cvar_t r_buffermegs[R_BUFFERDATA_COUNT]
Definition gl_rmain.c:249
cvar_t r_showlighting
Definition gl_rmain.c:88
cvar_t r_shadows_shadowmapbias
Definition gl_rmain.c:131
void R_GLSL_Restart_f(cmd_state_t *cmd)
Definition gl_rmain.c:1394
cvar_t r_motionblur_velocityfactor
Definition gl_rmain.c:65
cvar_t r_motionblur_minblur
Definition gl_rmain.c:63
cvar_t r_shadows_drawafterrtlighting
Definition gl_rmain.c:127
cvar_t r_showspriteedges
Definition gl_rmain.c:93
cvar_t r_water_hideplayer
Definition gl_rmain.c:200
cvar_t r_hdr_irisadaptation_fade_up
Definition gl_rmain.c:225
cvar_t r_glsl_offsetmapping_reliefmapping_steps
Definition gl_rmain.c:175
cvar_t r_q1bsp_lightmap_updates_enabled
Definition gl_rmain.c:257
cvar_t r_batch_dynamicbuffer
Definition gl_rmain.c:240
cvar_t r_hdr_irisadaptation_value
Definition gl_rmain.c:224
cvar_t r_hdr_irisadaptation_minvalue
Definition gl_rmain.c:222
cvar_t r_hdr_irisadaptation_fade_down
Definition gl_rmain.c:226
cvar_t r_drawfog
Definition gl_rmain.c:139
cvar_t r_motionblur
Definition gl_rmain.c:59
cvar_t r_bloom_colorsubtract
Definition gl_rmain.c:215
cvar_t r_shadows_focus
Definition gl_rmain.c:129
cvar_t r_fullbrights
Definition gl_rmain.c:122
cvar_t r_viewscale_fpsscaling_stepsize
Definition gl_rmain.c:166
cvar_t r_fullbright_directed_pitch_relative
Definition gl_rmain.c:118
cvar_t r_nolerp_list
Definition gl_rmain.c:204
cvar_t r_usedepthtextures
Definition gl_rmain.c:159
cvar_t r_bloom_colorexponent
Definition gl_rmain.c:214
cvar_t r_shadows_darken
Definition gl_rmain.c:124
cvar_t r_glsl_postprocess_uservec1_enable
Definition gl_rmain.c:185
cvar_t r_water_clippingplanebias
Definition gl_rmain.c:194
cvar_t r_q1bsp_skymasking
Definition gl_rmain.c:132
cvar_t r_draw2d
Definition gl_rmain.c:97
cvar_t r_transparent_sortmaxdist
Definition gl_rmain.c:142
cvar_t r_smoothnormals_areaweighting
Definition gl_rmain.c:229
cvar_t r_fullbright_directed_diffuse
Definition gl_rmain.c:116
cvar_t r_test
Definition gl_rmain.c:235
cvar_t r_bloom
Definition gl_rmain.c:208
cvar_t r_shadows_throwdirection
Definition gl_rmain.c:126
cvar_t r_transparent_useplanardistance
Definition gl_rmain.c:81
cvar_t r_motionblur_velocityfactor_minspeed
Definition gl_rmain.c:66
cvar_t r_celoutlines
Definition gl_rmain.c:145
cvar_t r_glsl_deluxemapping
Definition gl_rmain.c:171
static void gl_main_start(void)
Definition gl_rmain.c:3049
cvar_t r_q1bsp_lightmap_updates_hidden_surfaces
Definition gl_rmain.c:259
cvar_t r_showtris
Definition gl_rmain.c:86
cvar_t r_viewscale_fpsscaling_stepmax
Definition gl_rmain.c:167
cvar_t r_viewscale
Definition gl_rmain.c:162
cvar_t r_shadows
Definition gl_rmain.c:123
cvar_t r_showcollisionbrushes_polygonfactor
Definition gl_rmain.c:90
cvar_t r_motionblur_velocityfactor_maxspeed
Definition gl_rmain.c:67
cvar_t gl_fogdensity
Definition gl_rmain.c:148
cvar_t r_cullentities_trace
Definition gl_rmain.c:101
cvar_t r_colorfringe
Definition gl_rmain.c:189
cvar_t r_water_scissormode
Definition gl_rmain.c:198
cvar_t r_polygonoffset_decals_factor
Definition gl_rmain.c:135
cvar_t gl_fogblue
Definition gl_rmain.c:151
cvar_t r_hdr_irisadaptation_maxvalue
Definition gl_rmain.c:223
cvar_t r_viewscale_fpsscaling_target
Definition gl_rmain.c:168
cvar_t r_viewscale_fpsscaling_min
Definition gl_rmain.c:164
cvar_t r_water_resolutionmultiplier
Definition gl_rmain.c:195
cvar_t r_glsl_offsetmapping_reliefmapping_refinesteps
Definition gl_rmain.c:176
cvar_t r_water_refractdistort
Definition gl_rmain.c:196
cvar_t r_glsl_vertextextureblend_usebothalphas
Definition gl_rmain.c:245
cvar_t r_farclip_world
Definition gl_rmain.c:75
cvar_t r_drawportals
Definition gl_rmain.c:95
cvar_t r_waterscroll
Definition gl_rmain.c:206
cvar_t r_cullentities_trace_eyejitter
Definition gl_rmain.c:109
cvar_t r_glsl_postprocess_uservec3_enable
Definition gl_rmain.c:187
cvar_t r_polygonoffset_decals_offset
Definition gl_rmain.c:136
static void gl_main_newmap(void)
Definition gl_rmain.c:3202
cvar_t r_bloom_scenebrightness
Definition gl_rmain.c:216
cvar_t r_celshading
Definition gl_rmain.c:144
mempool_t * r_main_mempool
Definition gl_rmain.c:42
cvar_t r_fullbright
Definition gl_rmain.c:112
cvar_t r_bloom_colorscale
Definition gl_rmain.c:209
cvar_t r_motionblur_mousefactor
Definition gl_rmain.c:68
cvar_t r_transparent_sortsurfacesbynearest
Definition gl_rmain.c:80
cvar_t r_showoverdraw
Definition gl_rmain.c:82
cvar_t r_glsl_offsetmapping
Definition gl_rmain.c:172
cvar_t r_batch_multidraw_mintriangles
Definition gl_rmain.c:238
cvar_t r_water_lowquality
Definition gl_rmain.c:199
cvar_t r_cullentities_trace_tempentitysamples
Definition gl_rmain.c:104
cvar_t r_cullentities_trace_delay
Definition gl_rmain.c:108
cvar_t r_bloom_resolution
Definition gl_rmain.c:213
cvar_t r_hdr_irisadaptation
Definition gl_rmain.c:220
cvar_t gl_fogenable
Definition gl_rmain.c:147
cvar_t r_fullbright_directed
Definition gl_rmain.c:114
cvar_t r_drawentities
Definition gl_rmain.c:96
cvar_t r_dynamic
Definition gl_rmain.c:121
cvar_t r_useinfinitefarclip
Definition gl_rmain.c:73
cvar_t r_bloom_brighten
Definition gl_rmain.c:211
cvar_t r_shadows_shadowmapscale
Definition gl_rmain.c:130
cvar_t r_batch_multidraw
Definition gl_rmain.c:237
cvar_t r_hdr_scenebrightness
Definition gl_rmain.c:218
cvar_t r_motionblur_maxblur
Definition gl_rmain.c:64
cvar_t r_motionblur_averaging
Definition gl_rmain.c:61
cvar_t r_fxaa
Definition gl_rmain.c:190
cvar_t r_fullbright_directed_ambient
Definition gl_rmain.c:115
cvar_t r_transparent_sortarraysize
Definition gl_rmain.c:143
cvar_t r_motionblur_mousefactor_maxspeed
Definition gl_rmain.c:70
cvar_t r_showparticleedges
Definition gl_rmain.c:94
cvar_t r_fullbright_directed_pitch
Definition gl_rmain.c:117
cvar_t r_water_reflectdistort
Definition gl_rmain.c:197
cvar_t r_showsurfaces
Definition gl_rmain.c:85
cvar_t r_motionblur_mousefactor_minspeed
Definition gl_rmain.c:69
cvar_t gl_fogstart
Definition gl_rmain.c:152
cvar_t r_hdr_irisadaptation_radius
Definition gl_rmain.c:227
cvar_t r_polygonoffset_submodel_factor
Definition gl_rmain.c:133
cvar_t r_drawexteriormodel
Definition gl_rmain.c:100
cvar_t developer_texturelogging
Definition gl_rmain.c:231
cvar_t r_viewscale_fpsscaling_multiply
Definition gl_rmain.c:165
cvar_t r_water
Definition gl_rmain.c:192
cvar_t r_glsl_offsetmapping_lod
Definition gl_rmain.c:178
cvar_t r_glsl_offsetmapping_scale
Definition gl_rmain.c:177
cvar_t r_showbboxes
Definition gl_rmain.c:83
cvar_t r_batch_debugdynamicvertexpath
Definition gl_rmain.c:239
static void R_InitShaderModeInfo(void)
Definition gl_rmain.c:987
cvar_t r_shadows_throwdistance
Definition gl_rmain.c:125
cvar_t gl_lightmaps
Definition gl_rmain.c:233
cvar_t r_transparent_sortmindist
Definition gl_rmain.c:141
cvar_t r_cullentities_trace_samples
Definition gl_rmain.c:103
cvar_t r_showbboxes_client
Definition gl_rmain.c:84
cvar_t r_framedatasize
Definition gl_rmain.c:248
cvar_t r_wateralpha
Definition gl_rmain.c:120
cvar_t r_glsl_postprocess_uservec2_enable
Definition gl_rmain.c:186
cvar_t r_showcollisionbrushes
Definition gl_rmain.c:89
cvar_t r_fog_clear
Definition gl_rmain.c:138
cvar_t r_damageblur
Definition gl_rmain.c:60
cvar_t r_fog_exp2
Definition gl_rmain.c:137
cvar_t r_glsl_postprocess_uservec4
Definition gl_rmain.c:184
cvar_t gl_fogred
Definition gl_rmain.c:149
cvar_t r_cullentities_trace_expand
Definition gl_rmain.c:106
cvar_t r_shownormals
Definition gl_rmain.c:87
cvar_t r_transparent
Definition gl_rmain.c:78
cvar_t r_bloom_blur
Definition gl_rmain.c:212
cvar_t r_sortentities
Definition gl_rmain.c:110
cvar_t r_transparent_alphatocoverage
Definition gl_rmain.c:79
cvar_t r_glsl_saturation_redcompensate
Definition gl_rmain.c:243
cvar_t r_glsl_offsetmapping_reliefmapping
Definition gl_rmain.c:174
cvar_t r_speeds
Definition gl_rmain.c:111
cvar_t r_polygonoffset_submodel_offset
Definition gl_rmain.c:134
static void gl_main_shutdown(void)
Definition gl_rmain.c:3146
cvar_t r_showcollisionbrushes_polygonoffset
Definition gl_rmain.c:91
cvar_t r_showdisabledepthtest
Definition gl_rmain.c:92
cvar_t r_drawworld
Definition gl_rmain.c:98
cvar_t r_motionblur_randomize
Definition gl_rmain.c:62
cvar_t r_drawviewmodel
Definition gl_rmain.c:99
cvar_t r_nearclip
Definition gl_rmain.c:76
cvar_t r_cullentities_trace_pad
Definition gl_rmain.c:107
cvar_t gl_fogend
Definition gl_rmain.c:153
cvar_t r_cullentities_trace_enlarge
Definition gl_rmain.c:105
cvar_t r_glsl_postprocess_uservec4_enable
Definition gl_rmain.c:188
cvar_t r_hdr_irisadaptation_multiplier
Definition gl_rmain.c:221
cvar_t r_glsl_postprocess_uservec1
Definition gl_rmain.c:181
cvar_t r_lerpsprites
Definition gl_rmain.c:202
cvar_t r_water_cameraentitiesonly
Definition gl_rmain.c:193
cvar_t r_rendertarget_debug
Definition gl_rmain.c:161
cvar_t r_glsl_offsetmapping_steps
Definition gl_rmain.c:173
cvar_t r_q1bsp_lightmap_updates_combine
Definition gl_rmain.c:258
cvar_t r_texture_dds_load
Definition gl_rmain.c:156
cvar_t r_lerplightstyles
Definition gl_rmain.c:205
cvar_t r_depthfirst
Definition gl_rmain.c:72
cvar_t r_deformvertexes
Definition gl_rmain.c:77
cvar_t r_glsl_saturation
Definition gl_rmain.c:242
cvar_t gl_skyclip
Definition gl_rmain.c:154
cvar_t r_viewfbo
Definition gl_rmain.c:160
cvar_t r_lerpmodels
Definition gl_rmain.c:203
static void R_GLSL_DumpShader_f(cmd_state_t *cmd)
Definition gl_rmain.c:1419
cvar_t r_farclip_base
Definition gl_rmain.c:74
cvar_t r_glsl_postprocess_uservec2
Definition gl_rmain.c:182
cvar_t r_glsl_postprocess
Definition gl_rmain.c:180
cvar_t r_hdr_glowintensity
Definition gl_rmain.c:219
cvar_t r_cullentities_trace_entityocclusion
Definition gl_rmain.c:102
cvar_t r_transparentdepthmasking
Definition gl_rmain.c:140
cvar_t r_glsl_postprocess_uservec3
Definition gl_rmain.c:183
cvar_t r_glsl_offsetmapping_lod_distance
Definition gl_rmain.c:179
cvar_t r_glsl_skeletal
Definition gl_rmain.c:170
cvar_t gl_foggreen
Definition gl_rmain.c:150
cvar_t r_viewscale_fpsscaling
Definition gl_rmain.c:163
cvar_t r_texture_dds_save
Definition gl_rmain.c:157
#define NULL
Definition qtypes.h:12
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
Definition r_modules.c:25
@ R_BUFFERDATA_COUNT
uniform buffer
Definition render.h:534
#define Mem_AllocPool(name, flags, parent)
Definition zone.h:104

Referenced by Render_Init().

◆ gl_main_newmap()

static void gl_main_newmap ( void  )
static

Definition at line 3202 of file gl_rmain.c.

3203{
3204 // FIXME: move this code to client
3205 char *entities, entname[MAX_QPATH];
3206 if (r_qwskincache)
3210 if (cl.worldmodel)
3211 {
3212 dpsnprintf(entname, sizeof(entname), "%s.ent", cl.worldnamenoextension);
3213 if ((entities = (char *)FS_LoadFile(entname, tempmempool, true, NULL)))
3214 {
3215 CL_ParseEntityLump(entities);
3216 Mem_Free(entities);
3217 return;
3218 }
3219 if (cl.worldmodel->brush.entities)
3220 CL_ParseEntityLump(cl.worldmodel->brush.entities);
3221 }
3223
3226}
client_state_t cl
Definition cl_main.c:115
void CL_ParseEntityLump(char *entdata)
Definition cl_parse.c:384
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:997
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
Definition fs.c:3525
static void R_Main_FreeViewCache(void)
Definition gl_rmain.c:2997
void R_FrameData_Reset(void)
free all R_FrameData memory
Definition gl_rmain.c:3501
static r_qwskincache_t * r_qwskincache
Definition gl_rmain.c:308
void R_BufferData_Reset(void)
frees all dynamic buffers
Definition gl_rmain.c:3621
static int r_qwskincache_size
Definition gl_rmain.c:309
#define MAX_QPATH
max length of a quake game pathname
Definition qdefs.h:169
struct model_s * worldmodel
Definition client.h:935
char worldnamenoextension[MAX_QPATH]
Definition client.h:901
mempool_t * tempmempool
Definition zone.c:794
#define Mem_Free(mem)
Definition zone.h:96

Referenced by GL_Main_Init().

◆ gl_main_shutdown()

static void gl_main_shutdown ( void  )
static

Definition at line 3146 of file gl_rmain.c.

3147{
3153
3155
3156 switch(vid.renderpath)
3157 {
3158 case RENDERPATH_GL32:
3159 case RENDERPATH_GLES2:
3160#if defined(GL_SAMPLES_PASSED) && !defined(USE_GLES2)
3161 if (r_maxqueries)
3163#endif
3164 break;
3165 }
3167 r_numqueries = 0;
3168 r_maxqueries = 0;
3169 memset(r_queries, 0, sizeof(r_queries));
3170
3173
3174 // clear out the r_skinframe state
3176 memset(&r_skinframe, 0, sizeof(r_skinframe));
3177
3178 if (r_svbsp.nodes)
3180 memset(&r_svbsp, 0, sizeof (r_svbsp));
3193 //r_texture_fogintensity = NULL;
3194 memset(&r_fb, 0, sizeof(r_fb));
3196
3200}
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
Definition cmd.c:25
rtexture_t * r_texture_whitecube
Definition gl_rmain.c:277
rtexturepool_t * r_main_texturepool
Definition gl_rmain.c:43
unsigned int r_maxqueries
Definition gl_rmain.c:299
rtexture_t * r_texture_grey128
Definition gl_rmain.c:274
memexpandablearray_t r_glsl_permutationarray
storage for permutations linked in the hash table
Definition gl_rmain.c:938
rtexture_t * r_texture_fogattenuation
Definition gl_rmain.c:279
r_skinframe_t r_skinframe
Definition gl_rmain.c:2165
rtexture_t * r_texture_black
Definition gl_rmain.c:275
r_glsl_permutation_t * r_glsl_permutation
currently selected permutation
Definition gl_rmain.c:936
int r_texture_numcubemaps
Definition gl_rmain.c:294
r_framebufferstate_t r_fb
Definition gl_rmain.c:265
void R_RenderTarget_FreeUnused(qbool force)
Definition gl_rmain.c:4531
unsigned int r_numqueries
Definition gl_rmain.c:298
rtexture_t * r_texture_blanknormalmap
Definition gl_rmain.c:272
rtexture_t * r_texture_fogheighttexture
Definition gl_rmain.c:280
void R_AnimCache_Free(void)
Animation cache prevents re-generating mesh data for an animated model multiple times in one frame fo...
Definition gl_rmain.c:3766
svbsp_t r_svbsp
shadow volume bsp struct with automatically growing nodes buffer
Definition gl_rmain.c:268
r_glsl_permutation_t * r_glsl_permutationhash[SHADERMODE_COUNT][SHADERPERMUTATION_HASHSIZE]
information about each possible shader permutation
Definition gl_rmain.c:934
rtexture_t * loadingscreentexture
Definition cl_screen.c:1596
rtexture_t * r_texture_gammaramps
Definition gl_rmain.c:281
rtexture_t * r_texture_white
Definition gl_rmain.c:273
rtexture_t * r_texture_normalizationcube
Definition gl_rmain.c:278
unsigned int r_shadow_occlusion_buf
Definition r_shadow.c:136
unsigned int r_queries[MAX_OCCLUSION_QUERIES]
Definition gl_rmain.c:297
void R_FreeTexturePool(rtexturepool_t **rtexturepool)
memexpandablearray_t rendertargets
Definition render.h:909
memexpandablearray_t array
Definition gl_rmain.c:2161
svbsp_node_t * nodes
Definition svbsp.h:30
renderpath_t renderpath
Definition vid.h:87
@ RENDERPATH_GLES2
Definition vid.h:38
@ RENDERPATH_GL32
Definition vid.h:37
viddef_t vid
Definition vid_shared.c:64
void Mem_ExpandableArray_FreeArray(memexpandablearray_t *l)
Definition zone.c:683

Referenced by GL_Main_Init().

◆ gl_main_start()

static void gl_main_start ( void  )
static

Definition at line 3049 of file gl_rmain.c.

3050{
3063
3066
3067 switch(vid.renderpath)
3068 {
3069 case RENDERPATH_GL32:
3070 case RENDERPATH_GLES2:
3071 r_loadnormalmap = true;
3072 r_loadgloss = true;
3073 r_loadfog = false;
3074#ifdef GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT
3076#endif
3077 break;
3078 }
3079
3083
3084 r_numqueries = 0;
3085 r_maxqueries = 0;
3086 memset(r_queries, 0, sizeof(r_queries));
3087
3090
3091 // due to caching of texture_t references, the collision cache must be reset
3093
3094 // set up r_skinframe loading system for textures
3095 memset(&r_skinframe, 0, sizeof(r_skinframe));
3098
3103#ifndef USE_GLES2
3105#endif //USE_GLES2
3109 //r_texture_fogintensity = NULL;
3110 memset(&r_fb, 0, sizeof(r_fb));
3115 memset(&r_svbsp, 0, sizeof (r_svbsp));
3116
3119
3121
3122#ifdef __ANDROID__
3123 // For Steelstorm Android
3124 // FIXME CACHE the program and reload
3125 // FIXME see possible combinations for SS:BR android
3126 Con_DPrintf("Compiling most used shaders for SS:BR android... START\n");
3140 Con_DPrintf("Compiling most used shaders for SS:BR android... END\n");
3141#endif
3142}
void Collision_Cache_Reset(qbool resetlimits)
Definition collision.c:1480
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1490
static void R_BuildWhiteCube(void)
Definition gl_rmain.c:401
static qbool r_savedds
Definition gl_rmain.c:51
static void R_BuildBlankTextures(void)
Definition gl_rmain.c:371
qbool r_loadfog
Definition gl_rmain.c:49
static void R_BuildNormalizationCube(void)
Definition gl_rmain.c:408
static void R_SetupShader_SetPermutationGLSL(unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:1346
int r_uniformbufferalignment
Definition gl_rmain.c:270
static qbool r_loadnormalmap
Definition gl_rmain.c:47
cubemapinfo_t * r_texture_cubemaps[MAX_CUBEMAPS]
Definition gl_rmain.c:295
static void R_BuildNoTexture(void)
Definition gl_rmain.c:396
static qbool r_loadgloss
Definition gl_rmain.c:48
static qbool r_loaddds
Definition gl_rmain.c:50
rtexturepool_t * R_AllocTexturePool(void)
#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT
Definition glquake.h:425
float fogmasktable_density
Definition render.h:435
unsigned int loadsequence
Definition gl_rmain.c:2160
qbool ext_texture_compression_s3tc
Definition vid.h:48
viddef_support_t support
Definition vid.h:96
void Mem_ExpandableArray_NewArray(memexpandablearray_t *l, mempool_t *mempool, size_t recordsize, int numrecordsperarray)
Definition zone.c:675

Referenced by GL_Main_Init().

◆ R_AnimCache_CacheVisibleEntities()

void R_AnimCache_CacheVisibleEntities ( void  )

generate animcache data for all entities marked visible

Definition at line 3882 of file gl_rmain.c.

3883{
3884 int i;
3885
3886 // TODO: thread this
3887 // NOTE: R_PrepareRTLights() also caches entities
3888
3889 for (i = 0;i < r_refdef.scene.numentities;i++)
3892}
qbool R_AnimCache_GetEntity(entity_render_t *ent, qbool wantnormals, qbool wanttangents)
get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangent...
Definition gl_rmain.c:3797
entity_render_t ** entities
renderable entities (excluding world)
Definition render.h:366
r_refdef_viewcache_t viewcache
Definition render.h:412
r_refdef_scene_t scene
Definition render.h:423
unsigned char * entityvisible
which entities are currently visible for this viewpoint (the used range is 0...r_refdef....
Definition render.h:338

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_AnimCache_ClearCache()

void R_AnimCache_ClearCache ( void  )

clear the animcache pointers on all known render entities

Definition at line 3770 of file gl_rmain.c.

3771{
3772 int i;
3773 entity_render_t *ent;
3774
3775 for (i = 0;i < r_refdef.scene.numentities;i++)
3776 {
3777 ent = r_refdef.scene.entities[i];
3778 ent->animcache_vertex3f = NULL;
3781 ent->animcache_normal3f = NULL;
3794 }
3795}
float * animcache_skeletaltransform3x4
Definition client.h:396
r_meshbuffer_t * animcache_vertex3f_vertexbuffer
Definition client.h:381
float * animcache_normal3f
Definition client.h:383
int animcache_skeletaltransform3x4size
Definition client.h:399
int animcache_vertex3f_bufferoffset
Definition client.h:382
r_meshbuffer_t * animcache_svector3f_vertexbuffer
Definition client.h:387
r_meshbuffer_t * animcache_tvector3f_vertexbuffer
Definition client.h:390
float * animcache_vertex3f
Definition client.h:380
int animcache_svector3f_bufferoffset
Definition client.h:388
r_meshbuffer_t * animcache_skeletaltransform3x4buffer
Definition client.h:397
r_meshbuffer_t * animcache_normal3f_vertexbuffer
Definition client.h:384
float * animcache_svector3f
Definition client.h:386
int animcache_tvector3f_bufferoffset
Definition client.h:391
float * animcache_tvector3f
Definition client.h:389
int animcache_skeletaltransform3x4offset
Definition client.h:398
int animcache_normal3f_bufferoffset
Definition client.h:385

Referenced by R_RenderView().

◆ R_AnimCache_Free()

void R_AnimCache_Free ( void  )

Animation cache prevents re-generating mesh data for an animated model multiple times in one frame for lighting, shadowing, reflections, etc.

free all R_AnimCache memory

Definition at line 3766 of file gl_rmain.c.

3767{
3768}

Referenced by gl_main_shutdown(), and gl_main_start().

◆ R_AnimCache_GetEntity()

qbool R_AnimCache_GetEntity ( entity_render_t ent,
qbool  wantnormals,
qbool  wanttangents 
)

get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangents)

Definition at line 3797 of file gl_rmain.c.

3798{
3799 model_t *model = ent->model;
3800 int numvertices;
3801
3802 // see if this ent is worth caching
3803 if (!model || !model->Draw || !model->AnimateVertices)
3804 return false;
3805 // nothing to cache if it contains no animations and has no skeleton
3806 if (!model->surfmesh.isanimated && !(model->num_bones && ent->skeleton && ent->skeleton->relativetransforms))
3807 return false;
3808 // see if it is already cached for gpuskeletal
3810 return false;
3811 // see if it is already cached as a mesh
3812 if (ent->animcache_vertex3f)
3813 {
3814 // check if we need to add normals or tangents
3815 if (ent->animcache_normal3f)
3816 wantnormals = false;
3817 if (ent->animcache_svector3f)
3818 wanttangents = false;
3819 if (!wantnormals && !wanttangents)
3820 return false;
3821 }
3822
3823 // check which kind of cache we need to generate
3824 if (r_gpuskeletal && model->num_bones > 0 && model->surfmesh.data_skeletalindex4ub)
3825 {
3826 // cache the skeleton so the vertex shader can use it
3830 ent->animcache_skeletaltransform3x4 = (float *)R_FrameData_Alloc(sizeof(float[3][4]) * model->num_bones);
3832 // note: this can fail if the buffer is at the grow limit
3833 ent->animcache_skeletaltransform3x4size = sizeof(float[3][4]) * model->num_bones;
3835 }
3836 else if (ent->animcache_vertex3f)
3837 {
3838 // mesh was already cached but we may need to add normals/tangents
3839 // (this only happens with multiple views, reflections, cameras, etc)
3840 if (wantnormals || wanttangents)
3841 {
3842 numvertices = model->surfmesh.num_vertices;
3843 if (wantnormals)
3844 ent->animcache_normal3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3845 if (wanttangents)
3846 {
3847 ent->animcache_svector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3848 ent->animcache_tvector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3849 }
3850 model->AnimateVertices(model, ent->frameblend, ent->skeleton, NULL, wantnormals ? ent->animcache_normal3f : NULL, wanttangents ? ent->animcache_svector3f : NULL, wanttangents ? ent->animcache_tvector3f : NULL);
3854 }
3855 }
3856 else
3857 {
3858 // generate mesh cache
3859 numvertices = model->surfmesh.num_vertices;
3860 ent->animcache_vertex3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3861 if (wantnormals)
3862 ent->animcache_normal3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3863 if (wanttangents)
3864 {
3865 ent->animcache_svector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3866 ent->animcache_tvector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3867 }
3869 if (wantnormals || wanttangents)
3870 {
3874 }
3878 }
3879 return true;
3880}
static qbool r_gpuskeletal
Definition gl_rmain.c:52
void * R_FrameData_Alloc(size_t size)
allocate some temporary memory for your purposes
Definition gl_rmain.c:3547
r_meshbuffer_t * R_BufferData_Store(size_t datasize, const void *data, r_bufferdata_type_t type, int *returnbufferoffset)
request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and of...
Definition gl_rmain.c:3715
#define max(A, B)
Definition mathlib.h:38
void Mod_Skeletal_BuildTransforms(const model_t *RESTRICT model, const frameblend_t *RESTRICT frameblend, const skeleton_t *skeleton, float *RESTRICT bonepose, float *RESTRICT boneposerelative)
Definition model_alias.c:65
@ r_stat_animcache_shape_count
Definition r_stats.h:67
@ r_stat_animcache_skeletal_bones
Definition r_stats.h:62
@ r_stat_animcache_shape_maxvertices
Definition r_stats.h:69
@ r_stat_animcache_skeletal_maxbones
Definition r_stats.h:63
@ r_stat_animcache_skeletal_count
Definition r_stats.h:61
@ r_stat_animcache_shade_count
Definition r_stats.h:64
@ r_stat_animcache_shape_vertices
Definition r_stats.h:68
@ r_stat_animcache_shade_vertices
Definition r_stats.h:65
@ r_stat_animcache_shade_maxvertices
Definition r_stats.h:66
@ R_BUFFERDATA_UNIFORM
index buffer - 32bit (because D3D cares)
Definition render.h:533
frameblend_t frameblend[MAX_FRAMEBLENDS]
Definition client.h:374
model_t * model
Definition client.h:344
skeleton_t * skeleton
Definition client.h:376
void(* AnimateVertices)(const struct model_s *RESTRICT model, const struct frameblend_s *RESTRICT frameblend, const struct skeleton_s *skeleton, float *RESTRICT vertex3f, float *RESTRICT normal3f, float *RESTRICT svector3f, float *RESTRICT tvector3f)
surfmesh_t surfmesh
void(* Draw)(struct entity_render_s *ent)
int num_bones
int stats[r_stat_count]
Definition render.h:471
struct matrix4x4_s * relativetransforms
Definition protocol.h:427
qbool isanimated
unsigned char * data_skeletalindex4ub

Referenced by R_AnimCache_CacheVisibleEntities(), R_Shadow_PrepareLight(), and R_Shadow_PrepareModelShadows().

◆ R_BlendFuncFlags()

static int R_BlendFuncFlags ( int  src,
int  dst 
)
static

Definition at line 1521 of file gl_rmain.c.

1522{
1523 int r = 0;
1524
1525 // a blendfunc allows colormod if:
1526 // a) it can never keep the destination pixel invariant, or
1527 // b) it can keep the destination pixel invariant, and still can do so if colormodded
1528 // this is to prevent unintended side effects from colormod
1529
1530 // a blendfunc allows fog if:
1531 // blend(fog(src), fog(dst)) == fog(blend(src, dst))
1532 // this is to prevent unintended side effects from fog
1533
1534 // these checks are the output of fogeval.pl
1535
1544 if(src == GL_ONE && dst == GL_ONE) r |= BLENDFUNC_ALLOWS_FOG_HACK0;
1546 if(src == GL_ONE && dst == GL_ZERO) r |= BLENDFUNC_ALLOWS_FOG;
1556 if(src == GL_ZERO && dst == GL_ONE) r |= BLENDFUNC_ALLOWS_FOG;
1558
1559 return r;
1560}
#define BLENDFUNC_ALLOWS_FOG_HACK0
Definition gl_rmain.c:1518
#define BLENDFUNC_ALLOWS_FOG_HACKALPHA
Definition gl_rmain.c:1519
#define BLENDFUNC_ALLOWS_FOG
Definition gl_rmain.c:1517
#define BLENDFUNC_ALLOWS_COLORMOD
Definition gl_rmain.c:1516
#define GL_ONE_MINUS_DST_ALPHA
Definition glquake.h:82
#define GL_ONE_MINUS_DST_COLOR
Definition glquake.h:78
#define GL_SRC_ALPHA
Definition glquake.h:79
#define GL_SRC_COLOR
Definition glquake.h:75
#define GL_ZERO
Definition glquake.h:73
#define GL_ONE_MINUS_SRC_ALPHA
Definition glquake.h:80
#define GL_ONE
Definition glquake.h:74
#define GL_DST_ALPHA
Definition glquake.h:81
#define GL_DST_COLOR
Definition glquake.h:77
#define GL_ONE_MINUS_SRC_COLOR
Definition glquake.h:76
dp_FragColor r

Referenced by R_GetCurrentTexture(), and R_SetupShader_Surface().

◆ R_BlendView()

static void R_BlendView ( rtexture_t viewcolortexture,
int  fbo,
rtexture_t depthtexture,
rtexture_t colortexture,
int  x,
int  y,
int  width,
int  height 
)
static

Definition at line 5325 of file gl_rmain.c.

5326{
5327 uint64_t permutation;
5328 float uservecs[4][4];
5331
5333
5334 if (r_fb.bloomwidth)
5335 {
5336 // make the bloom texture
5338 }
5339
5340#if _MSC_VER >= 1400
5341#define sscanf sscanf_s
5342#endif
5343 memset(uservecs, 0, sizeof(uservecs));
5345 sscanf(r_glsl_postprocess_uservec1.string, "%f %f %f %f", &uservecs[0][0], &uservecs[0][1], &uservecs[0][2], &uservecs[0][3]);
5347 sscanf(r_glsl_postprocess_uservec2.string, "%f %f %f %f", &uservecs[1][0], &uservecs[1][1], &uservecs[1][2], &uservecs[1][3]);
5349 sscanf(r_glsl_postprocess_uservec3.string, "%f %f %f %f", &uservecs[2][0], &uservecs[2][1], &uservecs[2][2], &uservecs[2][3]);
5351 sscanf(r_glsl_postprocess_uservec4.string, "%f %f %f %f", &uservecs[3][0], &uservecs[3][1], &uservecs[3][2], &uservecs[3][3]);
5352
5353 // render to the screen fbo
5354 R_ResetViewRendering2D(fbo, depthtexture, colortexture, x, y, width, height);
5355 GL_Color(1, 1, 1, 1);
5357
5360
5362 {
5364 if (rt && rt->colortexture[0])
5365 {
5368 }
5369 }
5370
5372 switch(vid.renderpath)
5373 {
5374 case RENDERPATH_GL32:
5375 case RENDERPATH_GLES2:
5376 permutation =
5396 break;
5397 }
5400}
qbool R_Stereo_ColorMasking(void)
Definition cl_screen.c:2097
unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2) *3]
Definition gl_backend.c:242
int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2) *3]
Definition gl_backend.c:241
void R_Mesh_TexBind(unsigned int unitnum, rtexture_t *tex)
void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtriangles, const int *element3i, const r_meshbuffer_t *element3i_indexbuffer, int element3i_bufferoffset, const unsigned short *element3s, const r_meshbuffer_t *element3s_indexbuffer, int element3s_bufferoffset)
void GL_Color(float cr, float cg, float cb, float ca)
void R_Mesh_PrepareVertices_Mesh_Arrays(int numvertices, const float *vertex3f, const float *svector3f, const float *tvector3f, const float *normal3f, const float *color4f, const float *texcoordtexture2f, const float *texcoordlightmap2f)
void GL_BlendFunc(int blendfunc1, int blendfunc2)
void R_ResetViewRendering2D(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4485
void R_EntityMatrix(const matrix4x4_t *matrix)
Definition gl_rmain.c:4425
const float r_screenvertex3f[12]
vertex coordinates for a quad that covers the screen exactly
Definition gl_rmain.c:313
static void R_Bloom_MakeTexture(void)
Definition gl_rmain.c:5121
GLenum GLsizei width
Definition glquake.h:621
GLenum GLsizei GLsizei height
Definition glquake.h:621
GLsizei const GLfloat * value
Definition glquake.h:739
GLint GLenum GLint GLint y
Definition glquake.h:650
GLint GLenum GLint x
Definition glquake.h:650
const matrix4x4_t identitymatrix
Definition matrixlib.c:9
@ r_stat_bloom_drawpixels
Definition r_stats.h:44
#define SHADERPERMUTATION_POSTPROCESSING
user defined postprocessing (postprocessing only)
Definition render.h:87
#define SHADERPERMUTATION_BLOOM
bloom (postprocessing only)
Definition render.h:85
@ SHADERMODE_POSTPROCESS
postprocessing shader (r_glsl_postprocess)
Definition render.h:53
#define SHADERPERMUTATION_VIEWTINT
view tint (postprocessing only), use vertex colors (generic only)
Definition render.h:75
#define SHADERPERMUTATION_SATURATION
saturation (postprocessing only)
Definition render.h:77
#define SHADERPERMUTATION_GAMMARAMPS
gamma (postprocessing only)
Definition render.h:82
float value
Definition cvar.h:74
const char * string
Definition cvar.h:71
r_rendertarget_t * rt_bloom
Definition render.h:893
r_rendertarget_t * rt_screen
Definition render.h:892
float viewblend[4]
Definition render.h:421
r_refdef_view_t view
Definition render.h:411
float texcoord2f[8]
Definition render.h:824
rtexture_t * colortexture[4]
Definition render.h:839
qbool vid_gammatables_trivial
void * Mem_ExpandableArray_RecordAtIndex(const memexpandablearray_t *l, size_t index)
Definition zone.c:780

Referenced by R_RenderView().

◆ R_BlendView_IsTrivial()

static qbool R_BlendView_IsTrivial ( int  viewwidth,
int  viewheight,
int  width,
int  height 
)
static

Definition at line 5232 of file gl_rmain.c.

5233{
5234 // Scaling requested?
5235 if (viewwidth != width || viewheight != height)
5236 return false;
5237 // Higher bit depth or explicit FBO requested?
5238 if (r_viewfbo.integer)
5239 return false;
5240 // Non-trivial postprocessing shader permutation?
5241 if (r_fb.bloomwidth
5242 || r_refdef.viewblend[3] > 0
5246 return false;
5247 // Other reasons for a non-trivial default postprocessing shader?
5248 // (See R_CompileShader_CheckStaticParms but only those relevant for MODE_POSTPROCESS in shader_glsl.h)
5249 // Skip: if (r_glsl_saturation_redcompensate.integer) (already covered by saturation above).
5250 // Skip: if (r_glsl_postprocess.integer) (already covered by r_glsl_postprocess above).
5251 // Skip: if (r_glsl_postprocess_uservec1_enable.integer) (already covered by r_glsl_postprocessing above).
5252 if (r_fxaa.integer)
5253 return false;
5254 if (r_colorfringe.value)
5255 return false;
5256 return true;
5257}

Referenced by R_RenderView().

◆ R_Bloom_MakeTexture()

static void R_Bloom_MakeTexture ( void  )
static

Definition at line 5121 of file gl_rmain.c.

5122{
5123 int x, range, dir;
5124 float xoffset, yoffset, r, brighten;
5125 float colorscale = r_bloom_colorscale.value;
5127 r_rendertarget_t *prev, *cur;
5128 textype_t textype = r_fb.rt_screen->colortextype[0];
5129
5131
5133
5134 // scale down screen texture to the bloom texture size
5136 prev = r_fb.rt_screen;
5138 R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
5141 GL_DepthTest(false);
5143 GL_Color(colorscale, colorscale, colorscale, 1);
5145 // TODO: do boxfilter scale-down in shader?
5146 R_SetupShader_Generic(prev->colortexture[0], false, true, true);
5149 // we now have a properly scaled bloom image
5150
5151 // multiply bloom image by itself as many times as desired to darken it
5152 // TODO: if people actually use this it could be done more quickly in the previous shader pass
5153 for (x = 1;x < min(r_bloom_colorexponent.value, 32);)
5154 {
5155 prev = cur;
5157 R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
5158 x *= 2;
5159 r = bound(0, r_bloom_colorexponent.value / x, 1); // always 0.5 to 1
5160 if(x <= 2)
5162 GL_BlendFunc(GL_SRC_COLOR, GL_ZERO); // square it
5163 GL_Color(1,1,1,1); // no fix factor supported here
5165 R_SetupShader_Generic(prev->colortexture[0], false, true, false);
5168 }
5170
5174 if(range >= 1)
5175 brighten *= (3 * range) / (2 * range - 1); // compensate for the "dot particle"
5176
5177 for (dir = 0;dir < 2;dir++)
5178 {
5179 prev = cur;
5181 R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
5182 // blend on at multiple vertical offsets to achieve a vertical blur
5183 // TODO: do offset blends using GLSL
5184 // TODO instead of changing the texcoords, change the target positions to prevent artifacts at edges
5188 R_SetupShader_Generic(prev->colortexture[0], false, true, false);
5190 for (x = -range;x <= range;x++)
5191 {
5192 if (!dir){xoffset = 0;yoffset = x;}
5193 else {xoffset = x;yoffset = 0;}
5194 xoffset /= (float)prev->texturewidth;
5195 yoffset /= (float)prev->textureheight;
5196 // compute a texcoord array with the specified x and y offset
5205 // this r value looks like a 'dot' particle, fading sharply to
5206 // black at the edges
5207 // (probably not realistic but looks good enough)
5208 //r = ((range*range+1)/((float)(x*x+1)))/(range*2+1);
5209 //r = brighten/(range*2+1);
5210 r = brighten / (range * 2 + 1);
5211 if(range >= 1)
5212 r *= (1 - x*x/(float)((range+1)*(range+1)));
5213 if (r <= 0)
5214 continue;
5216 GL_Color(r, r, r, 1);
5225 }
5226 }
5227
5228 // now we have the bloom image, so keep track of it
5229 r_fb.rt_bloom = cur;
5230}
void GL_Clear(int mask, const float *colorvalue, float depthvalue, int stencilvalue)
void GL_CullFace(int state)
void GL_DepthTest(int state)
void R_SetViewport(const r_viewport_t *v)
Definition gl_backend.c:896
void R_Viewport_InitOrtho(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float x1, float y1, float x2, float y2, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:586
void R_Mesh_SetRenderTargets(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4)
void R_Mesh_PrepareVertices_Generic_Arrays(int numvertices, const float *vertex3f, const float *color4f, const float *texcoord2f)
r_rendertarget_t * R_RenderTarget_Get(int texturewidth, int textureheight, textype_t depthtextype, qbool depthisrenderbuffer, textype_t colortextype0, textype_t colortextype1, textype_t colortextype2, textype_t colortextype3)
Definition gl_rmain.c:4572
void R_SetupShader_Generic(rtexture_t *t, qbool usegamma, qbool notrippy, qbool suppresstexalpha)
Definition gl_rmain.c:1460
#define GL_NONE
Definition glquake.h:127
#define CHECKGLERROR
Definition glquake.h:1058
GLint GLint GLint yoffset
Definition glquake.h:648
GLint GLint xoffset
Definition glquake.h:648
#define GL_COLOR_BUFFER_BIT
Definition glquake.h:170
#define min(A, B)
Definition mathlib.h:37
#define bound(min, num, max)
Definition mathlib.h:34
@ r_stat_bloom
Definition r_stats.h:42
textype_t
Definition r_textures.h:44
@ TEXTYPE_UNUSED
Definition r_textures.h:46
precision highp float
Definition shader_glsl.h:45
vec2 dir
float offsettexcoord2f[8]
Definition render.h:901
textype_t colortextype[4]
Definition render.h:829

Referenced by R_BlendView().

◆ R_Bloom_StartFrame()

static void R_Bloom_StartFrame ( void  )
static

Definition at line 5027 of file gl_rmain.c.

5028{
5029 int screentexturewidth, screentextureheight;
5031 double scale;
5032
5033 // clear the pointers to rendertargets from last frame as they're stale
5035 r_fb.rt_bloom = NULL;
5036
5037 switch (vid.renderpath)
5038 {
5039 case RENDERPATH_GL32:
5041 if (r_viewfbo.integer == 2) textype = TEXTYPE_COLORBUFFER16F;
5042 if (r_viewfbo.integer == 3) textype = TEXTYPE_COLORBUFFER32F;
5043 break;
5044 case RENDERPATH_GLES2:
5045 r_fb.usedepthtextures = false;
5046 break;
5047 }
5048
5050 {
5051 double actualframetime;
5052 double targetframetime;
5053 double adjust;
5059 {
5060 if (adjust > 0)
5062 else
5064 }
5067 }
5068 else
5069 viewscalefpsadjusted = 1.0f;
5070
5072 if (vid.samples)
5073 scale *= sqrt(vid.samples); // supersampling
5074 scale = bound(0.03125f, scale, 4.0f);
5075 screentexturewidth = (int)ceil(r_refdef.view.width * scale);
5076 screentextureheight = (int)ceil(r_refdef.view.height * scale);
5077 screentexturewidth = bound(1, screentexturewidth, (int)vid.maxtexturesize_2d);
5078 screentextureheight = bound(1, screentextureheight, (int)vid.maxtexturesize_2d);
5079
5080 // set bloomwidth and bloomheight to the bloom resolution that will be
5081 // used (often less than the screen resolution for faster rendering)
5082 r_fb.bloomheight = bound(1, r_bloom_resolution.value * 0.75f, screentextureheight);
5083 r_fb.bloomwidth = r_fb.bloomheight * screentexturewidth / screentextureheight;
5084 r_fb.bloomwidth = bound(1, r_fb.bloomwidth, screentexturewidth);
5087
5089 {
5093 }
5094 if (!r_bloom.integer)
5096
5097 // allocate motionblur ghost texture if needed - this is the only persistent texture and is only useful on the main view
5098 if (r_refdef.view.ismain && (r_fb.screentexturewidth != screentexturewidth || r_fb.screentextureheight != screentextureheight || r_fb.textype != textype))
5099 {
5100 if (r_fb.ghosttexture)
5103
5104 r_fb.screentexturewidth = screentexturewidth;
5105 r_fb.screentextureheight = screentextureheight;
5106 r_fb.textype = textype;
5107
5109 {
5110 if (r_motionblur.value > 0 || r_damageblur.value > 0)
5112 r_fb.ghosttexture_valid = false;
5113 }
5114 }
5115
5116 r_fb.rt_screen = R_RenderTarget_Get(screentexturewidth, screentextureheight, TEXTYPE_DEPTHBUFFER24STENCIL8, true, textype, TEXTYPE_UNUSED, TEXTYPE_UNUSED, TEXTYPE_UNUSED);
5117
5118 r_refdef.view.clear = true;
5119}
qbool R_Stereo_Active(void)
Definition cl_screen.c:2102
static int(ZEXPORT *qz_inflate)(z_stream *strm
float viewscalefpsadjusted
Definition gl_rmain.c:4390
void R_FreeTexture(rtexture_t *rt)
rtexture_t * R_LoadTexture2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
#define TEXF_FORCELINEAR
Definition r_textures.h:19
@ TEXTYPE_COLORBUFFER
Definition r_textures.h:84
@ TEXTYPE_COLORBUFFER32F
Definition r_textures.h:88
@ TEXTYPE_DEPTHBUFFER24STENCIL8
Definition r_textures.h:94
@ TEXTYPE_COLORBUFFER16F
Definition r_textures.h:86
#define TEXF_CLAMP
Definition r_textures.h:15
#define TEXF_RENDERTARGET
Definition r_textures.h:37
qbool ghosttexture_valid
Definition render.h:905
rtexture_t * ghosttexture
Definition render.h:895
textype_t textype
Definition render.h:888
double lastdrawscreentime
Definition render.h:467
qbool clear
whether to call R_ClearScreen before rendering stuff
Definition render.h:305
qbool ismain
if true, this is the MAIN view (which is, after CSQC, copied into the scene for use e....
Definition render.h:309
unsigned int maxtexturesize_2d
Definition vid.h:90
int samples
Definition vid.h:80

Referenced by R_RenderView().

◆ R_BufferData_NewFrame()

void R_BufferData_NewFrame ( void  )

begin a new frame (recycle old buffers)

Definition at line 3686 of file gl_rmain.c.

3687{
3688 int type;
3689 r_bufferdata_buffer_t **p, *mem;
3690 // cycle to the next frame's buffers
3692 // if we ran out of space on the last time we used these buffers, free the old memory now
3693 for (type = 0;type < R_BUFFERDATA_COUNT;type++)
3694 {
3696 {
3698 // free all but the head buffer, this is how we recycle obsolete
3699 // buffers after they are no longer in use
3701 while (*p)
3702 {
3703 mem = *p;
3704 *p = (*p)->purge;
3705 if (mem->buffer)
3707 Mem_Free(mem);
3708 }
3709 // reset the current offset
3711 }
3712 }
3713}
void R_Mesh_DestroyMeshBuffer(r_meshbuffer_t *buffer)
#define R_BUFFERDATA_CYCLE
Definition gl_rmain.c:3606
static r_bufferdata_buffer_t * r_bufferdata_buffer[R_BUFFERDATA_CYCLE][R_BUFFERDATA_COUNT]
Definition gl_rmain.c:3618
static void R_BufferData_Resize(r_bufferdata_type_t type, qbool mustgrow, size_t minsize)
Definition gl_rmain.c:3644
static int r_bufferdata_cycle
Definition gl_rmain.c:3617
GLenum type
Definition glquake.h:655
r_bufferdata_type_t
enum of the various types of hardware buffer object used in rendering note that the r_buffermegs[] ar...
Definition render.h:529
struct r_bufferdata_buffer_s * purge
Definition gl_rmain.c:3610
r_meshbuffer_t * buffer
Definition gl_rmain.c:3613

Referenced by CL_UpdateScreen().

◆ R_BufferData_Reset()

void R_BufferData_Reset ( void  )

frees all dynamic buffers

free all dynamic vertex/index/uniform buffers

Definition at line 3621 of file gl_rmain.c.

3622{
3623 int cycle, type;
3624 r_bufferdata_buffer_t **p, *mem;
3625 for (cycle = 0;cycle < R_BUFFERDATA_CYCLE;cycle++)
3626 {
3627 for (type = 0;type < R_BUFFERDATA_COUNT;type++)
3628 {
3629 // free all buffers
3631 while (*p)
3632 {
3633 mem = *p;
3634 *p = (*p)->purge;
3635 if (mem->buffer)
3637 Mem_Free(mem);
3638 }
3639 }
3640 }
3641}

Referenced by gl_main_newmap(), gl_main_shutdown(), and gl_main_start().

◆ R_BufferData_Resize()

static void R_BufferData_Resize ( r_bufferdata_type_t  type,
qbool  mustgrow,
size_t  minsize 
)
static

Definition at line 3644 of file gl_rmain.c.

3645{
3647 size_t size;
3649
3650 // increase the cvar if we have to (but only if we already have a mem)
3651 if (mustgrow && mem)
3652 newvalue *= 2.0f;
3653 newvalue = bound(0.25f, newvalue, 256.0f);
3654 while (newvalue * 1024*1024 < minsize)
3655 newvalue *= 2.0f;
3656
3657 // clamp the cvar to valid range
3658 newvalue = bound(0.25f, newvalue, 256.0f);
3661
3662 // calculate size in bytes
3663 size = (size_t)(newvalue * 1024*1024);
3664 size = bound(131072, size, 256*1024*1024);
3665
3666 // allocate a new buffer if the size is different (purge old one later)
3667 // or if we were told we must grow the buffer
3668 if (!mem || mem->size != size || mustgrow)
3669 {
3670 mem = (r_bufferdata_buffer_t *)Mem_Alloc(r_main_mempool, sizeof(*mem));
3671 mem->size = size;
3672 mem->current = 0;
3674 mem->buffer = R_Mesh_CreateMeshBuffer(NULL, mem->size, "dynamicbuffervertex", false, false, true, false);
3675 else if (type == R_BUFFERDATA_INDEX16)
3676 mem->buffer = R_Mesh_CreateMeshBuffer(NULL, mem->size, "dynamicbufferindex16", true, false, true, true);
3677 else if (type == R_BUFFERDATA_INDEX32)
3678 mem->buffer = R_Mesh_CreateMeshBuffer(NULL, mem->size, "dynamicbufferindex32", true, false, true, false);
3679 else if (type == R_BUFFERDATA_UNIFORM)
3680 mem->buffer = R_Mesh_CreateMeshBuffer(NULL, mem->size, "dynamicbufferuniform", false, true, true, false);
3683 }
3684}
r_meshbuffer_t * R_Mesh_CreateMeshBuffer(const void *data, size_t size, const char *name, qbool isindexbuffer, qbool isuniformbuffer, qbool isdynamic, qbool isindex16)
GLuint GLuint GLintptr GLsizeiptr size
Definition glquake.h:631
@ R_BUFFERDATA_VERTEX
Definition render.h:530
@ R_BUFFERDATA_INDEX32
index buffer - 16bit (because D3D cares)
Definition render.h:532
@ R_BUFFERDATA_INDEX16
vertex buffer
Definition render.h:531
#define Mem_Alloc(pool, size)
Definition zone.h:92

Referenced by R_BufferData_NewFrame(), and R_BufferData_Store().

◆ R_BufferData_Store()

r_meshbuffer_t * R_BufferData_Store ( size_t  datasize,
const void data,
r_bufferdata_type_t  type,
int returnbufferoffset 
)

request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and offset, always successful

Definition at line 3715 of file gl_rmain.c.

3716{
3718 int offset = 0;
3719 int padsize;
3720
3721 *returnbufferoffset = 0;
3722
3723 // align size to a byte boundary appropriate for the buffer type, this
3724 // makes all allocations have aligned start offsets
3727 else
3728 padsize = (datasize + 15) & ~15;
3729
3730 // if we ran out of space in this buffer we must allocate a new one
3733
3734 // if the resize did not give us enough memory, fail
3736 Sys_Error("R_BufferData_Store: failed to create a new buffer of sufficient size\n");
3737
3739 offset = (int)mem->current;
3740 mem->current += padsize;
3741
3742 // upload the data to the buffer at the chosen offset
3743 if (offset == 0)
3744 R_Mesh_UpdateMeshBuffer(mem->buffer, NULL, mem->size, false, 0);
3746
3747 // count the usage for stats
3750
3751 // return the buffer offset
3753
3754 return mem->buffer;
3755}
void R_Mesh_UpdateMeshBuffer(r_meshbuffer_t *buffer, const void *data, size_t size, qbool subdata, size_t offset)
GLsizeiptr const GLvoid * data
Definition glquake.h:638
GLuint GLuint GLintptr offset
Definition glquake.h:631
@ r_stat_bufferdatasize_vertex
Definition r_stats.h:57
@ r_stat_bufferdatacurrent_vertex
Definition r_stats.h:53
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
Definition sys_shared.c:677

Referenced by Mod_Mesh_UploadDynamicBuffers(), R_AnimCache_GetEntity(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), R_Mesh_PrepareVertices_Mesh_Arrays(), R_Mesh_PrepareVertices_Vertex3f(), and RSurf_UploadBuffersForBatch().

◆ R_BuildBlankTextures()

static void R_BuildBlankTextures ( void  )
static

Definition at line 371 of file gl_rmain.c.

372{
373 unsigned char data[4];
374 data[2] = 128; // normal X
375 data[1] = 128; // normal Y
376 data[0] = 255; // normal Z
377 data[3] = 255; // height
379 data[0] = 255;
380 data[1] = 255;
381 data[2] = 255;
382 data[3] = 255;
384 data[0] = 128;
385 data[1] = 128;
386 data[2] = 128;
387 data[3] = 255;
389 data[0] = 0;
390 data[1] = 0;
391 data[2] = 0;
392 data[3] = 255;
394}
@ TEXTYPE_BGRA
Definition r_textures.h:53
#define TEXF_PERSISTENT
Definition r_textures.h:25

Referenced by gl_main_start().

◆ R_BuildFogHeightTexture()

static void R_BuildFogHeightTexture ( void  )
static

Definition at line 526 of file gl_rmain.c.

527{
528 unsigned char *inpixels;
529 int size;
530 int x;
531 int y;
532 int j;
533 float c[4];
534 float f;
535 inpixels = NULL;
539 if (!inpixels)
540 {
551 return;
552 }
556 r_refdef.fog_height_table2d = (unsigned char *)Mem_Alloc(r_main_mempool, size * size * 4);
559 // LadyHavoc: now the magic - what is that table2d for? it is a cooked
560 // average fog color table accounting for every fog layer between a point
561 // and the camera. (Note: attenuation is handled separately!)
562 for (y = 0;y < size;y++)
563 {
564 for (x = 0;x < size;x++)
565 {
566 Vector4Clear(c);
567 f = 0;
568 if (x < y)
569 {
570 for (j = x;j <= y;j++)
571 {
573 f++;
574 }
575 }
576 else
577 {
578 for (j = x;j >= y;j--)
579 {
581 f++;
582 }
583 }
584 f = 1.0f / f;
585 r_refdef.fog_height_table2d[(y*size+x)*4+0] = (unsigned char)(c[0] * f);
586 r_refdef.fog_height_table2d[(y*size+x)*4+1] = (unsigned char)(c[1] * f);
587 r_refdef.fog_height_table2d[(y*size+x)*4+2] = (unsigned char)(c[2] * f);
588 r_refdef.fog_height_table2d[(y*size+x)*4+3] = (unsigned char)(c[3] * f);
589 }
590 }
592}
#define dp_strlcpy(dst, src, dsize)
Definition common.h:298
unsigned char * loadimagepixelsbgra(const char *filename, qbool complain, qbool allowFixtrans, qbool convertsRGB, int *miplevel)
Definition image.c:1043
int image_width
Definition image.c:9
#define Vector4Clear(a)
Definition mathlib.h:81
#define Vector4Add(a, b, c)
Definition mathlib.h:88
#define TEXF_ALPHA
Definition r_textures.h:9
float f
unsigned char * fog_height_table1d
Definition render.h:450
unsigned char * fog_height_table2d
Definition render.h:451
char fogheighttexturename[64]
Definition render.h:455
int fog_height_tablesize
Definition render.h:452

Referenced by R_UpdateFog().

◆ R_BuildFogTexture()

static void R_BuildFogTexture ( void  )
static

Definition at line 470 of file gl_rmain.c.

471{
472 int x, b;
473#define FOGWIDTH 256
474 unsigned char data1[FOGWIDTH][4];
475 //unsigned char data2[FOGWIDTH][4];
476 double d, r, alpha;
477
482
484 for (x = 0;x < FOGMASKTABLEWIDTH;x++)
485 {
488 Con_DPrintf("%f ", d);
489 d = max(0, d);
492 else
495 Con_DPrintf(" : %f ", alpha);
498 Con_DPrintf(" = %f\n", alpha);
500 }
501
502 for (x = 0;x < FOGWIDTH;x++)
503 {
504 b = (int)(r_refdef.fogmasktable[x * (FOGMASKTABLEWIDTH - 1) / (FOGWIDTH - 1)] * 255);
505 data1[x][0] = b;
506 data1[x][1] = b;
507 data1[x][2] = b;
508 data1[x][3] = 255;
509 //data2[x][0] = 255 - b;
510 //data2[x][1] = 255 - b;
511 //data2[x][2] = 255 - b;
512 //data2[x][3] = 255;
513 }
515 {
516 R_UpdateTexture(r_texture_fogattenuation, &data1[0][0], 0, 0, 0, FOGWIDTH, 1, 1, 0);
517 //R_UpdateTexture(r_texture_fogattenuation, &data2[0][0], 0, 0, 0, FOGWIDTH, 1, 1, 0);
518 }
519 else
520 {
522 //r_texture_fogintensity = R_LoadTexture2D(r_main_texturepool, "fogintensity", FOGWIDTH, 1, &data2[0][0], TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_CLAMP, NULL);
523 }
524}
#define FOGWIDTH
void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int z, int width, int height, int depth, int combine)
GLclampf GLclampf GLclampf alpha
Definition glquake.h:641
cvar_t developer_extra
Definition host.c:50
#define FOGMASKTABLEWIDTH
Definition render.h:433
dp_FragColor b
float fogmasktable[FOGMASKTABLEWIDTH]
Definition render.h:434
float fogmasktable_start
Definition render.h:435
float fogrange
Definition render.h:430
float fogmasktable_alpha
Definition render.h:435
float fogmasktable_range
Definition render.h:435

Referenced by R_UpdateFog().

◆ R_BuildNormalizationCube()

static void R_BuildNormalizationCube ( void  )
static

Definition at line 408 of file gl_rmain.c.

409{
410 int x, y, side;
411 vec3_t v;
412 vec_t s, t, intensity;
413#define NORMSIZE 64
414 unsigned char *data;
415 data = (unsigned char *)Mem_Alloc(tempmempool, 6*NORMSIZE*NORMSIZE*4);
416 for (side = 0;side < 6;side++)
417 {
418 for (y = 0;y < NORMSIZE;y++)
419 {
420 for (x = 0;x < NORMSIZE;x++)
421 {
422 s = (x + 0.5f) * (2.0f / NORMSIZE) - 1.0f;
423 t = (y + 0.5f) * (2.0f / NORMSIZE) - 1.0f;
424 switch(side)
425 {
426 default:
427 case 0:
428 v[0] = 1;
429 v[1] = -t;
430 v[2] = -s;
431 break;
432 case 1:
433 v[0] = -1;
434 v[1] = -t;
435 v[2] = s;
436 break;
437 case 2:
438 v[0] = s;
439 v[1] = 1;
440 v[2] = t;
441 break;
442 case 3:
443 v[0] = s;
444 v[1] = -1;
445 v[2] = -t;
446 break;
447 case 4:
448 v[0] = s;
449 v[1] = -t;
450 v[2] = 1;
451 break;
452 case 5:
453 v[0] = -s;
454 v[1] = -t;
455 v[2] = -1;
456 break;
457 }
458 intensity = 127.0f / sqrt(DotProduct(v, v));
459 data[((side*64+y)*64+x)*4+2] = (unsigned char)(128.0f + intensity * v[0]);
460 data[((side*64+y)*64+x)*4+1] = (unsigned char)(128.0f + intensity * v[1]);
461 data[((side*64+y)*64+x)*4+0] = (unsigned char)(128.0f + intensity * v[2]);
462 data[((side*64+y)*64+x)*4+3] = 255;
463 }
464 }
465 }
467 Mem_Free(data);
468}
#define NORMSIZE
rtexture_t * R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
const GLdouble * v
Definition glquake.h:761
float vec_t
Definition qtypes.h:64
float intensity
Definition snd_mix.c:326

Referenced by gl_main_start().

◆ R_BuildNoTexture()

static void R_BuildNoTexture ( void  )
static

Definition at line 396 of file gl_rmain.c.

397{
399}
rtexture_t * r_texture_notexture
Definition gl_rmain.c:276
unsigned char * Image_GenerateNoTexture(void)
Definition image.c:1887
#define TEXF_MIPMAP
Definition r_textures.h:11

Referenced by gl_main_start().

◆ R_BuildWhiteCube()

static void R_BuildWhiteCube ( void  )
static

Definition at line 401 of file gl_rmain.c.

402{
403 unsigned char data[6*1*1*4];
404 memset(data, 255, sizeof(data));
406}

Referenced by gl_main_start().

◆ R_CalcBeam_Vertex3f()

void R_CalcBeam_Vertex3f ( float vert,
const float org1,
const float org2,
float  width 
)

Definition at line 6289 of file gl_rmain.c.

6290{
6292
6294
6295 // calculate 'right' vector for start
6299
6300 // calculate 'right' vector for end
6304
6305 vert[ 0] = org1[0] + width * right1[0];
6306 vert[ 1] = org1[1] + width * right1[1];
6307 vert[ 2] = org1[2] + width * right1[2];
6308 vert[ 3] = org1[0] - width * right1[0];
6309 vert[ 4] = org1[1] - width * right1[1];
6310 vert[ 5] = org1[2] - width * right1[2];
6311 vert[ 6] = org2[0] - width * right2[0];
6312 vert[ 7] = org2[1] - width * right2[1];
6313 vert[ 8] = org2[2] - width * right2[2];
6314 vert[ 9] = org2[0] + width * right2[0];
6315 vert[10] = org2[1] + width * right2[1];
6316 vert[11] = org2[2] + width * right2[2];
6317}
#define VectorNormalize(v)
Definition mathlib.h:103
#define CrossProduct(a, b, c)
Definition mathlib.h:102
#define VectorSubtract(a, b, c)
Definition mathlib.h:98
vec3 normal
vec3_t origin
Definition render.h:267

Referenced by R_DrawParticle_TransparentCallback().

◆ R_CalcSprite_Vertex3f()

void R_CalcSprite_Vertex3f ( float vertex3f,
const vec3_t  origin,
const vec3_t  left,
const vec3_t  up,
float  scalex1,
float  scalex2,
float  scaley1,
float  scaley2 
)

Definition at line 6319 of file gl_rmain.c.

6320{
6321 vertex3f[ 0] = origin[0] + left[0] * scalex2 + up[0] * scaley1;
6322 vertex3f[ 1] = origin[1] + left[1] * scalex2 + up[1] * scaley1;
6323 vertex3f[ 2] = origin[2] + left[2] * scalex2 + up[2] * scaley1;
6324 vertex3f[ 3] = origin[0] + left[0] * scalex2 + up[0] * scaley2;
6325 vertex3f[ 4] = origin[1] + left[1] * scalex2 + up[1] * scaley2;
6326 vertex3f[ 5] = origin[2] + left[2] * scalex2 + up[2] * scaley2;
6327 vertex3f[ 6] = origin[0] + left[0] * scalex1 + up[0] * scaley2;
6328 vertex3f[ 7] = origin[1] + left[1] * scalex1 + up[1] * scaley2;
6329 vertex3f[ 8] = origin[2] + left[2] * scalex1 + up[2] * scaley2;
6330 vertex3f[ 9] = origin[0] + left[0] * scalex1 + up[0] * scaley1;
6331 vertex3f[10] = origin[1] + left[1] * scalex1 + up[1] * scaley1;
6332 vertex3f[11] = origin[2] + left[2] * scalex1 + up[2] * scaley1;
6333}
static vec3_t up
Definition sv_user.c:305

Referenced by R_BeginCoronaQuery(), R_DrawCorona(), R_Model_Sprite_Draw_TransparentCallback(), R_Shadow_DrawCursor_TransparentCallback(), and R_Shadow_DrawLightSprite_TransparentCallback().

◆ R_CalcTexCoordsForView()

static void R_CalcTexCoordsForView ( float  x,
float  y,
float  w,
float  h,
float  tw,
float  th,
float texcoord2f 
)
static

Definition at line 4555 of file gl_rmain.c.

4556{
4557 float iw = 1.0f / tw, ih = 1.0f / th, x1, y1, x2, y2;
4558 x1 = x * iw;
4559 x2 = (x + w) * iw;
4560 y1 = (th - y) * ih;
4561 y2 = (th - y - h) * ih;
4562 texcoord2f[0] = x1;
4563 texcoord2f[2] = x2;
4564 texcoord2f[4] = x2;
4565 texcoord2f[6] = x1;
4566 texcoord2f[1] = y1;
4567 texcoord2f[3] = y1;
4568 texcoord2f[5] = y2;
4569 texcoord2f[7] = y2;
4570}
vec3 y1
vec3 y2
vec3 x2
vec3 x1

Referenced by R_MotionBlurView(), and R_RenderTarget_Get().

◆ R_CanSeeBox()

qbool R_CanSeeBox ( int  numsamples,
vec_t  eyejitter,
vec_t  entboxenlarge,
vec_t  entboxexpand,
vec_t  pad,
vec3_t  eye,
vec3_t  entboxmins,
vec3_t  entboxmaxs 
)

Definition at line 3896 of file gl_rmain.c.

3897{
3898 long unsigned int i;
3899 int j;
3901 vec3_t boxmins, boxmaxs;
3903 vec3_t start;
3904 vec3_t end;
3906 static vec3_t positions[] = {
3907 { 0.5f, 0.5f, 0.5f },
3908 { 0.0f, 0.0f, 0.0f },
3909 { 0.0f, 0.0f, 1.0f },
3910 { 0.0f, 1.0f, 0.0f },
3911 { 0.0f, 1.0f, 1.0f },
3912 { 1.0f, 0.0f, 0.0f },
3913 { 1.0f, 0.0f, 1.0f },
3914 { 1.0f, 1.0f, 0.0f },
3915 { 1.0f, 1.0f, 1.0f },
3916 };
3917
3918 // sample count can be set to -1 to skip this logic, for flicker-prone objects
3919 if (numsamples < 0)
3920 return true;
3921
3922 // view origin is not used for culling in portal/reflection/refraction renders or isometric views
3924 return true;
3925
3927 return true;
3928
3929 // expand the eye box a little
3930 eyemins[0] = eye[0] - eyejitter;
3931 eyemaxs[0] = eye[0] + eyejitter;
3932 eyemins[1] = eye[1] - eyejitter;
3933 eyemaxs[1] = eye[1] + eyejitter;
3934 eyemins[2] = eye[2] - eyejitter;
3935 eyemaxs[2] = eye[2] + eyejitter;
3936 // expand the box a little
3937 boxmins[0] = (entboxenlarge + 1) * entboxmins[0] - entboxenlarge * entboxmaxs[0] - entboxexpand;
3938 boxmaxs[0] = (entboxenlarge + 1) * entboxmaxs[0] - entboxenlarge * entboxmins[0] + entboxexpand;
3939 boxmins[1] = (entboxenlarge + 1) * entboxmins[1] - entboxenlarge * entboxmaxs[1] - entboxexpand;
3940 boxmaxs[1] = (entboxenlarge + 1) * entboxmaxs[1] - entboxenlarge * entboxmins[1] + entboxexpand;
3941 boxmins[2] = (entboxenlarge + 1) * entboxmins[2] - entboxenlarge * entboxmaxs[2] - entboxexpand;
3942 boxmaxs[2] = (entboxenlarge + 1) * entboxmaxs[2] - entboxenlarge * entboxmins[2] + entboxexpand;
3943 // make an even larger box for the acceptable area
3944 padmins[0] = boxmins[0] - pad;
3945 padmaxs[0] = boxmaxs[0] + pad;
3946 padmins[1] = boxmins[1] - pad;
3947 padmaxs[1] = boxmaxs[1] + pad;
3948 padmins[2] = boxmins[2] - pad;
3949 padmaxs[2] = boxmaxs[2] + pad;
3950
3951 // return true if eye overlaps enlarged box
3952 if (BoxesOverlap(boxmins, boxmaxs, eyemins, eyemaxs))
3953 return true;
3954
3955 VectorCopy(eye, start);
3956 // try specific positions in the box first - note that these can be cached
3958 {
3959 for (i = 0; i < sizeof(positions) / sizeof(positions[0]); i++)
3960 {
3961 trace_t trace;
3962 end[0] = boxmins[0] + (boxmaxs[0] - boxmins[0]) * positions[i][0];
3963 end[1] = boxmins[1] + (boxmaxs[1] - boxmins[1]) * positions[i][1];
3964 end[2] = boxmins[2] + (boxmaxs[2] - boxmins[2]) * positions[i][2];
3965 //trace_t trace = CL_TraceLine(start, end, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID, SUPERCONTENTS_SKY, MATERIALFLAGMASK_TRANSLUCENT, 0.0f, true, false, NULL, true, true);
3967 // not picky - if the trace ended anywhere in the box we're good
3968 if (BoxesOverlap(trace.endpos, trace.endpos, padmins, padmaxs))
3969 return true;
3970 }
3971 }
3972 else
3973 {
3974 // try center
3975 VectorMAM(0.5f, boxmins, 0.5f, boxmaxs, end);
3976 if (model->brush.TraceLineOfSight(model, start, end, padmins, padmaxs))
3977 return true;
3978 }
3979
3980 // try various random positions
3981 for (j = 0; j < numsamples; j++)
3982 {
3983 VectorSet(start, lhrandom(eyemins[0], eyemaxs[0]), lhrandom(eyemins[1], eyemaxs[1]), lhrandom(eyemins[2], eyemaxs[2]));
3984 VectorSet(end, lhrandom(boxmins[0], boxmaxs[0]), lhrandom(boxmins[1], boxmaxs[1]), lhrandom(boxmins[2], boxmaxs[2]));
3986 {
3987 trace_t trace = CL_TraceLine(start, end, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID, SUPERCONTENTS_SKY, MATERIALFLAGMASK_TRANSLUCENT, 0.0f, true, false, NULL, true, true);
3988 // not picky - if the trace ended anywhere in the box we're good
3989 if (BoxesOverlap(trace.endpos, trace.endpos, padmins, padmaxs))
3990 return true;
3991 }
3992 else if (model->brush.TraceLineOfSight(model, start, end, padmins, padmaxs))
3993 return true;
3994 }
3995
3996 return false;
3997}
#define SUPERCONTENTS_SKY
Definition bspfile.h:200
#define SUPERCONTENTS_SOLID
Definition bspfile.h:196
trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities, qbool hitsurfaces)
trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t end, int type, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask)
#define BoxesOverlap(a, b, c, d)
Definition mathlib.h:121
#define lhrandom(MIN, MAX)
LadyHavoc: this function never returns exactly MIN or exactly MAX, because of a QuakeC bug in id1 whe...
Definition mathlib.h:48
#define VectorMAM(scale1, b1, scale2, b2, c)
Definition mathlib.h:115
#define VectorCopy(a, b)
Definition mathlib.h:100
#define VectorSet(a, b, c, d)
Definition mathlib.h:95
#define MATERIALFLAGMASK_TRANSLUCENT
qbool(* TraceLineOfSight)(struct model_s *model, const vec3_t start, const vec3_t end, const vec3_t acceptmins, const vec3_t acceptmaxs)
model_brush_t brush
model_t * worldmodel
same as worldentity->model
Definition render.h:363
int usevieworiginculling
allows visibility culling based on the view origin (e.g.
Definition render.h:286
double endpos[3]
Definition collision.h:42
#define MOVE_NORMAL
Definition world.h:28

Referenced by R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_PrepareLight(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ R_CompileShader_AddStaticParms()

static void R_CompileShader_AddStaticParms ( unsigned int  mode,
uint64_t  permutation 
)
static

Definition at line 911 of file gl_rmain.c.

912{
914
915 // emit all
931}
#define R_COMPILESHADER_STATICPARM_EMIT(p, n)
Definition gl_rmain.c:906

Referenced by R_GLSL_CompilePermutation().

◆ R_CompileShader_CheckStaticParms()

qbool R_CompileShader_CheckStaticParms ( void  )

Definition at line 861 of file gl_rmain.c.

862{
866
867 // detect all
875 {
884 }
885 if (r_fxaa.integer)
889
892 if (r_shadow_shadowmappcf > 1)
894 else if (r_shadow_shadowmappcf)
902
904}
int r_shadow_shadowmappcf
Definition r_shadow.c:60
#define R_COMPILESHADER_STATICPARM_ENABLE(p)
Definition gl_rmain.c:857
qbool r_shadow_shadowmapsampler
Definition r_shadow.c:58
#define SHADERSTATICPARMS_COUNT
Definition gl_rmain.c:851
cvar_t r_shadow_glossexact
Definition r_shadow.c:152

Referenced by R_RenderView(), and R_Shadow_SetShadowMode().

◆ R_CullBox()

qbool R_CullBox ( const vec3_t  mins,
const vec3_t  maxs,
int  numplanes,
const mplane_t planes 
)

Definition at line 3478 of file gl_rmain.c.

3479{
3480 // nothing to ignore
3481 return _R_CullBox(mins, maxs, numplanes, planes, -1);
3482}
static qbool _R_CullBox(const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes, int ignore)
Definition gl_rmain.c:3453

Referenced by R_Q1BSP_RecursiveGetLightInfo_BIH(), R_Q1BSP_RecursiveGetLightInfo_BSP(), and R_Shadow_PrepareLight().

◆ R_CullFrustum()

qbool R_CullFrustum ( const vec3_t  mins,
const vec3_t  maxs 
)

Definition at line 3472 of file gl_rmain.c.

3473{
3474 // skip nearclip plane, it often culls portals when you are very close, and is almost never useful
3476}
int numfrustumplanes
Definition render.h:272
mplane_t frustum[6]
Definition render.h:273

Referenced by R_DrawDebugModel(), R_DrawPortals(), R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_BounceGrid_TracePhotons_Shot(), R_Shadow_PrepareLight(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ R_DebugLine()

void R_DebugLine ( vec3_t  start,
vec3_t  end 
)

Definition at line 10171 of file gl_rmain.c.

10172{
10173 model_t *mod = CL_Mesh_UI();
10175 int e0, e1, e2, e3;
10176 float offsetx, offsety, x1, y1, x2, y2, width = 1.0f;
10177 float r1 = 1.0f, g1 = 0.0f, b1 = 0.0f, alpha1 = 0.25f;
10178 float r2 = 1.0f, g2 = 1.0f, b2 = 0.0f, alpha2 = 0.25f;
10179 vec4_t w[2], s[2];
10180
10181 // transform to screen coords first
10182 Vector4Set(w[0], start[0], start[1], start[2], 1);
10183 Vector4Set(w[1], end[0], end[1], end[2], 1);
10186 x1 = s[0][0] * vid_conwidth.value / vid.width;
10187 y1 = (vid.height - s[0][1]) * vid_conheight.value / vid.height;
10188 x2 = s[1][0] * vid_conwidth.value / vid.width;
10189 y2 = (vid.height - s[1][1]) * vid_conheight.value / vid.height;
10190 //Con_DPrintf("R_DebugLine: %.0f,%.0f to %.0f,%.0f\n", x1, y1, x2, y2);
10191
10192 // add the line to the UI mesh for drawing later
10193
10194 // width is measured in real pixels
10195 if (fabs(x2 - x1) > fabs(y2 - y1))
10196 {
10197 offsetx = 0;
10199 }
10200 else
10201 {
10202 offsetx = 0.5f * width * vid_conwidth.value / vid.width;
10203 offsety = 0;
10204 }
10206 e0 = Mod_Mesh_IndexForVertex(mod, surf, x1 - offsetx, y1 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r1, g1, b1, alpha1);
10207 e1 = Mod_Mesh_IndexForVertex(mod, surf, x2 - offsetx, y2 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r2, g2, b2, alpha2);
10208 e2 = Mod_Mesh_IndexForVertex(mod, surf, x2 + offsetx, y2 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r2, g2, b2, alpha2);
10209 e3 = Mod_Mesh_IndexForVertex(mod, surf, x1 + offsetx, y1 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r1, g1, b1, alpha1);
10210 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
10211 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
10212
10213}
cvar_t vid_conheight
Definition cl_screen.c:56
cvar_t vid_conwidth
Definition cl_screen.c:55
#define CL_Mesh_UI()
Definition client.h:1372
void R_Viewport_TransformToScreen(const r_viewport_t *v, const vec4_t in, vec4_t out)
Definition gl_backend.c:382
#define Vector4Set(a, b, c, d, e)
Definition mathlib.h:85
#define MATERIALFLAG_VERTEXCOLOR
#define MATERIALFLAG_ALPHA
Definition model_brush.h:79
#define MATERIALFLAG_BLENDED
#define MATERIALFLAG_ALPHAGEN_VERTEX
#define MATERIALFLAG_WALL
Definition model_brush.h:89
#define MATERIALFLAG_NOSHADOW
msurface_t * Mod_Mesh_AddSurface(model_t *mod, texture_t *tex, qbool batchwithprevioussurface)
int Mod_Mesh_IndexForVertex(model_t *mod, msurface_t *surf, float x, float y, float z, float nx, float ny, float nz, float s, float t, float u, float v, float r, float g, float b, float a)
texture_t * Mod_Mesh_GetTexture(model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int defaultmaterialflags)
void Mod_Mesh_AddTriangle(model_t *mod, msurface_t *surf, int e0, int e1, int e2)
vec_t vec4_t[4]
Definition qtypes.h:68
describes the textures to use on a range of triangles in the model, and mins/maxs (AABB) for culling.
r_viewport_t viewport
note: if r_viewscale is used, the viewport.width and viewport.height may be less than width and heigh...
Definition render.h:296
int height
Definition vid.h:74
int width
Definition vid.h:73

Referenced by R_DrawParticle_TransparentCallback(), and R_Model_Sprite_Draw_TransparentCallback().

◆ R_DecalSystem_ApplySplatEntities()

static void R_DecalSystem_ApplySplatEntities ( const vec3_t  worldorigin,
const vec3_t  worldnormal,
float  r,
float  g,
float  b,
float  a,
float  s1,
float  t1,
float  s2,
float  t2,
float  worldsize,
unsigned int  decalsequence 
)
static

Definition at line 9509 of file gl_rmain.c.

9510{
9512 float worldmins[3];
9513 float worldmaxs[3];
9514 entity_render_t *ent;
9515
9516 worldmins[0] = worldorigin[0] - worldsize;
9517 worldmins[1] = worldorigin[1] - worldsize;
9518 worldmins[2] = worldorigin[2] - worldsize;
9519 worldmaxs[0] = worldorigin[0] + worldsize;
9520 worldmaxs[1] = worldorigin[1] + worldsize;
9521 worldmaxs[2] = worldorigin[2] + worldsize;
9522
9523 R_DecalSystem_SplatEntity(r_refdef.scene.worldentity, worldorigin, worldnormal, r, g, b, a, s1, t1, s2, t2, worldsize, decalsequence);
9524
9526 {
9528 if (!BoxesOverlap(ent->mins, ent->maxs, worldmins, worldmaxs))
9529 continue;
9530
9531 R_DecalSystem_SplatEntity(ent, worldorigin, worldnormal, r, g, b, a, s1, t1, s2, t2, worldsize, decalsequence);
9532 }
9533}
static void R_DecalSystem_SplatEntity(entity_render_t *ent, const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize, unsigned int decalsequence)
Definition gl_rmain.c:9350
dp_FragColor g
ret a
vec3_t mins
Definition client.h:372
vec3_t maxs
Definition client.h:372
entity_render_t * worldentity
the world
Definition render.h:360

Referenced by R_DecalSystem_ApplySplatEntitiesQueue().

◆ R_DecalSystem_ApplySplatEntitiesQueue()

static void R_DecalSystem_ApplySplatEntitiesQueue ( void  )
static

Definition at line 9565 of file gl_rmain.c.

9566{
9567 int i;
9569
9570 for (i = 0, queue = r_decalsystem_queue;i < r_decalsystem_numqueued;i++, queue++)
9571 R_DecalSystem_ApplySplatEntities(queue->worldorigin, queue->worldnormal, queue->color[0], queue->color[1], queue->color[2], queue->color[3], queue->tcrange[0], queue->tcrange[1], queue->tcrange[2], queue->tcrange[3], queue->worldsize, queue->decalsequence);
9573}
int r_decalsystem_numqueued
Definition gl_rmain.c:9546
r_decalsystem_splatqueue_t r_decalsystem_queue[MAX_DECALSYSTEM_QUEUE]
Definition gl_rmain.c:9547
static void R_DecalSystem_ApplySplatEntities(const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize, unsigned int decalsequence)
Definition gl_rmain.c:9509

Referenced by R_DrawModelDecals().

◆ R_DecalSystem_Reset()

void R_DecalSystem_Reset ( decalsystem_t decalsystem)

Definition at line 9170 of file gl_rmain.c.

9171{
9172 if (decalsystem->decals)
9173 Mem_Free(decalsystem->decals);
9174 memset(decalsystem, 0, sizeof(*decalsystem));
9175}
tridecal_t * decals
Definition client.h:62

Referenced by CL_UpdateNetworkEntities(), CLVM_free_edict(), R_DecalSystem_SplatEntity(), R_DrawModelDecals_Entity(), and R_DrawModelDecals_FadeEntity().

◆ R_DecalSystem_SpawnTriangle()

static void R_DecalSystem_SpawnTriangle ( decalsystem_t decalsystem,
const float v0,
const float v1,
const float v2,
const float t0,
const float t1,
const float t2,
const float c0,
const float c1,
const float c2,
int  triangleindex,
int  surfaceindex,
unsigned int  decalsequence 
)
static

Definition at line 9177 of file gl_rmain.c.

9178{
9180 tridecal_t *decals;
9181 int i;
9182
9183 // expand or initialize the system
9184 if (decalsystem->maxdecals <= decalsystem->numdecals)
9185 {
9186 decalsystem_t old = *decalsystem;
9188 decalsystem->maxdecals = max(16, decalsystem->maxdecals * 2);
9189 useshortelements = decalsystem->maxdecals * 3 <= 65536;
9190 decalsystem->decals = (tridecal_t *)Mem_Alloc(cls.levelmempool, decalsystem->maxdecals * (sizeof(tridecal_t) + sizeof(float[3][3]) + sizeof(float[3][2]) + sizeof(float[3][4]) + sizeof(int[3]) + (useshortelements ? sizeof(unsigned short[3]) : 0)));
9191 decalsystem->color4f = (float *)(decalsystem->decals + decalsystem->maxdecals);
9192 decalsystem->texcoord2f = (float *)(decalsystem->color4f + decalsystem->maxdecals*12);
9193 decalsystem->vertex3f = (float *)(decalsystem->texcoord2f + decalsystem->maxdecals*6);
9194 decalsystem->element3i = (int *)(decalsystem->vertex3f + decalsystem->maxdecals*9);
9195 decalsystem->element3s = (useshortelements ? ((unsigned short *)(decalsystem->element3i + decalsystem->maxdecals*3)) : NULL);
9196 if (decalsystem->numdecals)
9197 memcpy(decalsystem->decals, old.decals, decalsystem->numdecals * sizeof(tridecal_t));
9198 if (old.decals)
9199 Mem_Free(old.decals);
9200 for (i = 0;i < decalsystem->maxdecals*3;i++)
9201 decalsystem->element3i[i] = i;
9202 if (useshortelements)
9203 for (i = 0;i < decalsystem->maxdecals*3;i++)
9204 decalsystem->element3s[i] = i;
9205 }
9206
9207 // grab a decal and search for another free slot for the next one
9208 decals = decalsystem->decals;
9209 decal = decalsystem->decals + (i = decalsystem->freedecal++);
9210 for (i = decalsystem->freedecal;i < decalsystem->numdecals && decals[i].color4f[0][3];i++)
9211 ;
9212 decalsystem->freedecal = i;
9213 if (decalsystem->numdecals <= i)
9214 decalsystem->numdecals = i + 1;
9215
9216 // initialize the decal
9217 decal->lived = 0;
9218 decal->triangleindex = triangleindex;
9219 decal->surfaceindex = surfaceindex;
9220 decal->decalsequence = decalsequence;
9221 decal->color4f[0][0] = c0[0];
9222 decal->color4f[0][1] = c0[1];
9223 decal->color4f[0][2] = c0[2];
9224 decal->color4f[0][3] = 1;
9225 decal->color4f[1][0] = c1[0];
9226 decal->color4f[1][1] = c1[1];
9227 decal->color4f[1][2] = c1[2];
9228 decal->color4f[1][3] = 1;
9229 decal->color4f[2][0] = c2[0];
9230 decal->color4f[2][1] = c2[1];
9231 decal->color4f[2][2] = c2[2];
9232 decal->color4f[2][3] = 1;
9233 decal->vertex3f[0][0] = v0[0];
9234 decal->vertex3f[0][1] = v0[1];
9235 decal->vertex3f[0][2] = v0[2];
9236 decal->vertex3f[1][0] = v1[0];
9237 decal->vertex3f[1][1] = v1[1];
9238 decal->vertex3f[1][2] = v1[2];
9239 decal->vertex3f[2][0] = v2[0];
9240 decal->vertex3f[2][1] = v2[1];
9241 decal->vertex3f[2][2] = v2[2];
9242 decal->texcoord2f[0][0] = t0[0];
9243 decal->texcoord2f[0][1] = t0[1];
9244 decal->texcoord2f[1][0] = t1[0];
9245 decal->texcoord2f[1][1] = t1[1];
9246 decal->texcoord2f[2][0] = t2[0];
9247 decal->texcoord2f[2][1] = t2[1];
9248 TriangleNormal(v0, v1, v2, decal->plane);
9249 VectorNormalize(decal->plane);
9250 decal->plane[3] = DotProduct(v0, decal->plane);
9251}
client_static_t cls
Definition cl_main.c:114
GLfloat GLfloat GLfloat v2
Definition glquake.h:746
GLfloat v0
Definition glquake.h:738
GLfloat GLfloat v1
Definition glquake.h:742
#define TriangleNormal(a, b, c, n)
Definition mathlib.h:125
bool qbool
Definition qtypes.h:9
mempool_t * levelmempool
Definition client.h:572
int freedecal
Definition client.h:60
int maxdecals
Definition client.h:59
int * element3i
Definition client.h:66
int numdecals
Definition client.h:61
unsigned short * element3s
Definition client.h:67
float * color4f
Definition client.h:65
float * texcoord2f
Definition client.h:64
float * vertex3f
Definition client.h:63
float color4f[3][4]
Definition client.h:42

Referenced by R_DecalSystem_SplatTriangle().

◆ R_DecalSystem_SplatEntities()

void R_DecalSystem_SplatEntities ( const vec3_t  worldorigin,
const vec3_t  worldnormal,
float  r,
float  g,
float  b,
float  a,
float  s1,
float  t1,
float  s2,
float  t2,
float  worldsize 
)

Definition at line 9549 of file gl_rmain.c.

9550{
9552
9554 return;
9555
9557 VectorCopy(worldorigin, queue->worldorigin);
9558 VectorCopy(worldnormal, queue->worldnormal);
9559 Vector4Set(queue->color, r, g, b, a);
9560 Vector4Set(queue->tcrange, s1, t1, s2, t2);
9561 queue->worldsize = worldsize;
9562 queue->decalsequence = cl.decalsequence++;
9563}
#define MAX_DECALSYSTEM_QUEUE
Definition qdefs.h:150
unsigned int decalsequence
Definition client.h:979

Referenced by CL_ImmediateBloodStain(), and CL_SpawnDecalParticleForSurface().

◆ R_DecalSystem_SplatEntity()

static void R_DecalSystem_SplatEntity ( entity_render_t ent,
const vec3_t  worldorigin,
const vec3_t  worldnormal,
float  r,
float  g,
float  b,
float  a,
float  s1,
float  t1,
float  s2,
float  t2,
float  worldsize,
unsigned int  decalsequence 
)
static

Definition at line 9350 of file gl_rmain.c.

9351{
9353 decalsystem_t *decalsystem;
9354 qbool dynamic;
9355 model_t *model;
9356 const msurface_t *surface;
9357 const msurface_t *surfaces;
9358 const texture_t *texture;
9359 int numtriangles;
9360 int surfaceindex;
9361 int triangleindex;
9362 float localorigin[3];
9363 float localnormal[3];
9364 float localmins[3];
9365 float localmaxs[3];
9366 float localsize;
9367 //float normal[3];
9368 float planes[6][4];
9369 float angles[3];
9370 bih_t *bih;
9372 int bih_triangles[256];
9373 int bih_surfaces[256];
9374
9375 decalsystem = &ent->decalsystem;
9376 model = ent->model;
9377 if (!model || !ent->allowdecals || ent->alpha < 1 || (ent->flags & (RENDER_ADDITIVE | RENDER_NODEPTHTEST)))
9378 {
9380 return;
9381 }
9382
9383 if (!model->brush.data_leafs && !cl_decals_models.integer)
9384 {
9385 if (decalsystem->model)
9386 R_DecalSystem_Reset(decalsystem);
9387 return;
9388 }
9389
9390 if (decalsystem->model != model)
9391 R_DecalSystem_Reset(decalsystem);
9392 decalsystem->model = model;
9393
9394 RSurf_ActiveModelEntity(ent, true, false, false);
9395
9406
9407 //VectorCopy(localnormal, planes[4]);
9408 //VectorVectors(planes[4], planes[2], planes[0]);
9409 AnglesFromVectors(angles, localnormal, NULL, false);
9410 AngleVectors(angles, planes[0], planes[2], planes[4]);
9411 VectorNegate(planes[0], planes[1]);
9412 VectorNegate(planes[2], planes[3]);
9413 VectorNegate(planes[4], planes[5]);
9414 planes[0][3] = DotProduct(planes[0], localorigin) - localsize;
9415 planes[1][3] = DotProduct(planes[1], localorigin) - localsize;
9416 planes[2][3] = DotProduct(planes[2], localorigin) - localsize;
9417 planes[3][3] = DotProduct(planes[3], localorigin) - localsize;
9418 planes[4][3] = DotProduct(planes[4], localorigin) - localsize;
9419 planes[5][3] = DotProduct(planes[5], localorigin) - localsize;
9420
9421#if 1
9422// works
9423{
9425 Matrix4x4_CreateFromQuakeEntity(&forwardprojection, localorigin[0], localorigin[1], localorigin[2], angles[0], angles[1], angles[2], localsize);
9427}
9428#else
9429// broken
9430{
9431 float projectionvector[4][3];
9432 VectorScale(planes[0], ilocalsize, projectionvector[0]);
9433 VectorScale(planes[2], ilocalsize, projectionvector[1]);
9434 VectorScale(planes[4], ilocalsize, projectionvector[2]);
9435 projectionvector[0][0] = planes[0][0] * ilocalsize;
9436 projectionvector[0][1] = planes[1][0] * ilocalsize;
9437 projectionvector[0][2] = planes[2][0] * ilocalsize;
9438 projectionvector[1][0] = planes[0][1] * ilocalsize;
9439 projectionvector[1][1] = planes[1][1] * ilocalsize;
9440 projectionvector[1][2] = planes[2][1] * ilocalsize;
9441 projectionvector[2][0] = planes[0][2] * ilocalsize;
9442 projectionvector[2][1] = planes[1][2] * ilocalsize;
9443 projectionvector[2][2] = planes[2][2] * ilocalsize;
9448}
9449#endif
9450
9451 dynamic = model->surfmesh.isanimated;
9452 surfaces = model->data_surfaces;
9453
9454 bih = NULL;
9456 if(!dynamic)
9457 {
9458 if(model->render_bih.numleafs)
9459 bih = &model->render_bih;
9460 else if(model->collision_bih.numleafs)
9461 bih = &model->collision_bih;
9462 }
9463 if(bih)
9465 if(bih_triangles_count == 0)
9466 return;
9467 if(bih_triangles_count > (int) (sizeof(bih_triangles) / sizeof(*bih_triangles))) // hit too many, likely bad anyway
9468 return;
9469 if(bih_triangles_count > 0)
9470 {
9471 for (triangleindex = 0; triangleindex < bih_triangles_count; ++triangleindex)
9472 {
9473 surfaceindex = bih_surfaces[triangleindex];
9474 surface = surfaces + surfaceindex;
9475 texture = surface->texture;
9476 if (!texture)
9477 continue;
9479 continue;
9480 if (texture->surfaceflags & Q3SURFACEFLAG_NOMARKS)
9481 continue;
9482 R_DecalSystem_SplatTriangle(decalsystem, r, g, b, a, s1, t1, s2, t2, decalsequence, dynamic, planes, &projection, bih_triangles[triangleindex], surfaceindex);
9483 }
9484 }
9485 else
9486 {
9487 for (surfaceindex = model->submodelsurfaces_start;surfaceindex < model->submodelsurfaces_end;surfaceindex++)
9488 {
9489 surface = surfaces + surfaceindex;
9490 // check cull box first because it rejects more than any other check
9491 if (!dynamic && !BoxesOverlap(surface->mins, surface->maxs, localmins, localmaxs))
9492 continue;
9493 // skip transparent surfaces
9494 texture = surface->texture;
9495 if (!texture)
9496 continue;
9498 continue;
9499 if (texture->surfaceflags & Q3SURFACEFLAG_NOMARKS)
9500 continue;
9501 numtriangles = surface->num_triangles;
9502 for (triangleindex = 0; triangleindex < numtriangles; triangleindex++)
9503 R_DecalSystem_SplatTriangle(decalsystem, r, g, b, a, s1, t1, s2, t2, decalsequence, dynamic, planes, &projection, triangleindex + surface->num_firsttriangle, surfaceindex);
9504 }
9505 }
9506}
int BIH_GetTriangleListForBox(const bih_t *bih, int maxtriangles, int *trianglelist_idx, int *trianglelist_surf, const float *mins, const float *maxs)
Definition bih.c:211
void R_DecalSystem_Reset(decalsystem_t *decalsystem)
Definition gl_rmain.c:9170
static void R_DecalSystem_SplatTriangle(decalsystem_t *decalsystem, float r, float g, float b, float a, float s1, float t1, float s2, float t2, unsigned int decalsequence, qbool dynamic, float(*planes)[4], matrix4x4_t *projection, int triangleindex, int surfaceindex)
Definition gl_rmain.c:9257
rsurfacestate_t rsurface
Definition gl_rmain.c:6955
cvar_t cl_decals_models
void RSurf_ActiveModelEntity(const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass)
Definition gl_rmain.c:6957
GLenum GLenum GLuint texture
Definition glquake.h:612
void AnglesFromVectors(vec3_t angles, const vec3_t forward, const vec3_t up, qbool flippitch)
LadyHavoc: calculates pitch/yaw/roll angles from forward and up vectors.
Definition mathlib.c:650
void AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition mathlib.c:444
#define VectorNegate(a, b)
Definition mathlib.h:94
#define VectorScale(in, scale, out)
Definition mathlib.h:110
void Matrix4x4_Transform(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1657
void Matrix4x4_Transform3x3(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1685
void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale)
Definition matrixlib.c:715
void Matrix4x4_Invert_Simple(matrix4x4_t *out, const matrix4x4_t *in1)
Definition matrixlib.c:422
void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3])
Definition matrixlib.c:970
#define MATERIALFLAG_SKY
Definition model_brush.h:92
#define MATERIALFLAG_REFRACTION
#define MATERIALFLAG_WATERSHADER
#define MATERIALFLAG_NODEPTHTEST
Definition model_brush.h:83
#define MATERIALFLAG_SHORTDEPTHRANGE
#define Q3SURFACEFLAG_NOMARKS
#define RENDER_ADDITIVE
Definition protocol.h:371
#define RENDER_NODEPTHTEST
Definition protocol.h:370
Definition bih.h:66
int numleafs
Definition bih.h:69
model_t * model
Definition client.h:57
decalsystem_t decalsystem
Definition client.h:439
mleaf_t * data_leafs
bih_t collision_bih
int submodelsurfaces_end
msurface_t * data_surfaces
int submodelsurfaces_start
bih_t render_bih
float inversematrixscale
Definition render.h:728
matrix4x4_t inversematrix
Definition render.h:725

Referenced by R_DecalSystem_ApplySplatEntities().

◆ R_DecalSystem_SplatTriangle()

static void R_DecalSystem_SplatTriangle ( decalsystem_t decalsystem,
float  r,
float  g,
float  b,
float  a,
float  s1,
float  t1,
float  s2,
float  t2,
unsigned int  decalsequence,
qbool  dynamic,
float(*)  planes[4],
matrix4x4_t projection,
int  triangleindex,
int  surfaceindex 
)
static

Definition at line 9257 of file gl_rmain.c.

9258{
9259 int cornerindex;
9260 int index;
9261 float v[9][3];
9262 const float *vertex3f;
9263 const float *normal3f;
9264 int numpoints;
9265 float points[2][9][3];
9266 float temp[3];
9267 float tc[9][2];
9268 float f;
9269 float c[9][4];
9270 const int *e;
9271
9272 e = rsurface.modelelement3i + 3*triangleindex;
9273
9274 vertex3f = rsurface.modelvertex3f;
9275 normal3f = rsurface.modelnormal3f;
9276
9277 if (normal3f)
9278 {
9279 for (cornerindex = 0;cornerindex < 3;cornerindex++)
9280 {
9281 index = 3*e[cornerindex];
9282 VectorMA(vertex3f + index, cl_decals_bias.value, normal3f + index, v[cornerindex]);
9283 }
9284 }
9285 else
9286 {
9287 for (cornerindex = 0;cornerindex < 3;cornerindex++)
9288 {
9289 index = 3*e[cornerindex];
9290 VectorCopy(vertex3f + index, v[cornerindex]);
9291 }
9292 }
9293
9294 // cull backfaces
9295 //TriangleNormal(v[0], v[1], v[2], normal);
9296 //if (DotProduct(normal, localnormal) < 0.0f)
9297 // continue;
9298 // clip by each of the box planes formed from the projection matrix
9299 // if anything survives, we emit the decal
9300 numpoints = PolygonF_Clip(3 , v[0] , planes[0][0], planes[0][1], planes[0][2], planes[0][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[1][0]);
9301 if (numpoints < 3)
9302 return;
9303 numpoints = PolygonF_Clip(numpoints, points[1][0], planes[1][0], planes[1][1], planes[1][2], planes[1][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[0][0]);
9304 if (numpoints < 3)
9305 return;
9306 numpoints = PolygonF_Clip(numpoints, points[0][0], planes[2][0], planes[2][1], planes[2][2], planes[2][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[1][0]);
9307 if (numpoints < 3)
9308 return;
9309 numpoints = PolygonF_Clip(numpoints, points[1][0], planes[3][0], planes[3][1], planes[3][2], planes[3][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[0][0]);
9310 if (numpoints < 3)
9311 return;
9312 numpoints = PolygonF_Clip(numpoints, points[0][0], planes[4][0], planes[4][1], planes[4][2], planes[4][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[1][0]);
9313 if (numpoints < 3)
9314 return;
9315 numpoints = PolygonF_Clip(numpoints, points[1][0], planes[5][0], planes[5][1], planes[5][2], planes[5][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), v[0]);
9316 if (numpoints < 3)
9317 return;
9318 // some part of the triangle survived, so we have to accept it...
9319 if (dynamic)
9320 {
9321 // dynamic always uses the original triangle
9322 numpoints = 3;
9323 for (cornerindex = 0;cornerindex < 3;cornerindex++)
9324 {
9325 index = 3*e[cornerindex];
9326 VectorCopy(vertex3f + index, v[cornerindex]);
9327 }
9328 }
9329 for (cornerindex = 0;cornerindex < numpoints;cornerindex++)
9330 {
9331 // convert vertex positions to texcoords
9333 tc[cornerindex][0] = (temp[1]+1.0f)*0.5f * (s2-s1) + s1;
9334 tc[cornerindex][1] = (temp[2]+1.0f)*0.5f * (t2-t1) + t1;
9335 // calculate distance fade from the projection origin
9337 f = bound(0.0f, f, 1.0f);
9338 c[cornerindex][0] = r * f;
9339 c[cornerindex][1] = g * f;
9340 c[cornerindex][2] = b * f;
9341 c[cornerindex][3] = 1.0f;
9342 //VectorMA(v[cornerindex], cl_decals_bias.value, localnormal, v[cornerindex]);
9343 }
9344 if (dynamic)
9345 R_DecalSystem_SpawnTriangle(decalsystem, v[0], v[1], v[2], tc[0], tc[1], tc[2], c[0], c[1], c[2], triangleindex, surfaceindex, decalsequence);
9346 else
9347 for (cornerindex = 0;cornerindex < numpoints-2;cornerindex++)
9348 R_DecalSystem_SpawnTriangle(decalsystem, v[0], v[cornerindex+1], v[cornerindex+2], tc[0], tc[cornerindex+1], tc[cornerindex+2], c[0], c[cornerindex+1], c[cornerindex+2], -1, surfaceindex, decalsequence);
9349}
static void R_DecalSystem_SpawnTriangle(decalsystem_t *decalsystem, const float *v0, const float *v1, const float *v2, const float *t0, const float *t1, const float *t2, const float *c0, const float *c1, const float *c2, int triangleindex, int surfaceindex, unsigned int decalsequence)
Definition gl_rmain.c:9177
cvar_t cl_decals_bias
cvar_t cl_decals_newsystem_intensitymultiplier
#define VectorMA(a, scale, b, c)
Definition mathlib.h:113
int PolygonF_Clip(int innumpoints, const float *inpoints, float planenormalx, float planenormaly, float planenormalz, float planedist, float epsilon, int outfrontmaxpoints, float *outfrontpoints)
Definition polygon.c:99
void vec2 tc
int * modelelement3i
Definition render.h:654
float * modelvertex3f
Definition render.h:627
float * modelnormal3f
Definition render.h:636

Referenced by R_DecalSystem_SplatEntity().

◆ R_DrawBBoxMesh()

static void R_DrawBBoxMesh ( vec3_t  mins,
vec3_t  maxs,
float  cr,
float  cg,
float  cb,
float  ca 
)
static

Definition at line 6070 of file gl_rmain.c.

6071{
6072 int numvertices = BBOXEDGES * 8;
6073 float vertex3f[BBOXEDGES * 8 * 3], color4f[BBOXEDGES * 8 * 4];
6074 int numtriangles = BBOXEDGES * 12;
6075 unsigned short elements[BBOXEDGES * 36];
6076 int i, edge;
6077 float *v, *c, f1, f2, edgemins[3], edgemaxs[3];
6078
6079 RSurf_ActiveModelEntity(r_refdef.scene.worldentity, false, false, false);
6080
6082 GL_DepthMask(false);
6083 GL_DepthRange(0, 1);
6085
6086 for (edge = 0; edge < BBOXEDGES; edge++)
6087 {
6088 for (i = 0; i < 3; i++)
6089 {
6090 edgemins[i] = mins[i] + (maxs[i] - mins[i]) * bboxedges[edge][i] - 0.25f;
6091 edgemaxs[i] = mins[i] + (maxs[i] - mins[i]) * bboxedges[edge][3 + i] + 0.25f;
6092 }
6093 vertex3f[edge * 24 + 0] = edgemins[0]; vertex3f[edge * 24 + 1] = edgemins[1]; vertex3f[edge * 24 + 2] = edgemins[2];
6094 vertex3f[edge * 24 + 3] = edgemaxs[0]; vertex3f[edge * 24 + 4] = edgemins[1]; vertex3f[edge * 24 + 5] = edgemins[2];
6095 vertex3f[edge * 24 + 6] = edgemins[0]; vertex3f[edge * 24 + 7] = edgemaxs[1]; vertex3f[edge * 24 + 8] = edgemins[2];
6096 vertex3f[edge * 24 + 9] = edgemaxs[0]; vertex3f[edge * 24 + 10] = edgemaxs[1]; vertex3f[edge * 24 + 11] = edgemins[2];
6097 vertex3f[edge * 24 + 12] = edgemins[0]; vertex3f[edge * 24 + 13] = edgemins[1]; vertex3f[edge * 24 + 14] = edgemaxs[2];
6098 vertex3f[edge * 24 + 15] = edgemaxs[0]; vertex3f[edge * 24 + 16] = edgemins[1]; vertex3f[edge * 24 + 17] = edgemaxs[2];
6099 vertex3f[edge * 24 + 18] = edgemins[0]; vertex3f[edge * 24 + 19] = edgemaxs[1]; vertex3f[edge * 24 + 20] = edgemaxs[2];
6100 vertex3f[edge * 24 + 21] = edgemaxs[0]; vertex3f[edge * 24 + 22] = edgemaxs[1]; vertex3f[edge * 24 + 23] = edgemaxs[2];
6101 for (i = 0; i < 36; i++)
6102 elements[edge * 36 + i] = edge * 8 + bboxelements[i];
6103 }
6104 R_FillColors(color4f, numvertices, cr, cg, cb, ca);
6105 if (r_refdef.fogenabled)
6106 {
6107 for (i = 0, v = vertex3f, c = color4f; i < numvertices; i++, v += 3, c += 4)
6108 {
6109 f1 = RSurf_FogVertex(v);
6110 f2 = 1 - f1;
6111 c[0] = c[0] * f1 + r_refdef.fogcolor[0] * f2;
6112 c[1] = c[1] * f1 + r_refdef.fogcolor[1] * f2;
6113 c[2] = c[2] * f1 + r_refdef.fogcolor[2] * f2;
6114 }
6115 }
6116 R_Mesh_PrepareVertices_Generic_Arrays(numvertices, vertex3f, color4f, NULL);
6118 R_SetupShader_Generic_NoTexture(false, false);
6119 R_Mesh_Draw(0, numvertices, 0, numtriangles, NULL, NULL, 0, elements, NULL, 0);
6120}
void GL_DepthMask(int state)
void GL_DepthRange(float nearfrac, float farfrac)
void GL_PolygonOffset(float planeoffset, float depthoffset)
void R_Mesh_ResetTextureState(void)
void R_SetupShader_Generic_NoTexture(qbool usegamma, qbool notrippy)
Definition gl_rmain.c:1487
float RSurf_FogVertex(const float *v)
Definition gl_rmain.c:7360
void R_FillColors(float *out, int verts, float r, float g, float b, float a)
Definition gl_rmain.c:335
static const unsigned short bboxelements[36]
Definition gl_rmain.c:6038
static const float bboxedges[BBOXEDGES][6]
Definition gl_rmain.c:6049
#define BBOXEDGES
Definition gl_rmain.c:6048
qbool fogenabled
Definition render.h:445
float polygonoffset
Definition render.h:464
float fogcolor[3]
Definition render.h:429
float polygonfactor
Definition render.h:463

Referenced by R_DrawEntityBBoxes_Callback().

◆ R_DrawBrushModelsSky()

static int R_DrawBrushModelsSky ( void  )
static

only used if skyrendermasked, and normally returns false

Definition at line 4066 of file gl_rmain.c.

4067{
4068 int i, sky;
4069 entity_render_t *ent;
4070
4071 sky = false;
4072 for (i = 0;i < r_refdef.scene.numentities;i++)
4073 {
4075 continue;
4076 ent = r_refdef.scene.entities[i];
4077 if (!ent->model || !ent->model->DrawSky)
4078 continue;
4079 ent->model->DrawSky(ent);
4080 sky = true;
4081 }
4082 return sky;
4083}
void(* DrawSky)(struct entity_render_s *ent)

Referenced by R_RenderScene().

◆ R_DrawCustomSurface()

void R_DrawCustomSurface ( skinframe_t skinframe,
const matrix4x4_t texmatrix,
int  materialflags,
int  firstvertex,
int  numvertices,
int  firsttriangle,
int  numtriangles,
qbool  writedepth,
qbool  prepass,
qbool  ui 
)

Definition at line 10216 of file gl_rmain.c.

10217{
10218 static texture_t texture;
10219
10220 // fake enough texture and surface state to render this geometry
10221
10222 texture.update_lastrenderframe = -1; // regenerate this texture
10223 texture.basematerialflags = materialflags | MATERIALFLAG_CUSTOMSURFACE | MATERIALFLAG_WALL;
10224 texture.basealpha = 1.0f;
10225 texture.currentskinframe = skinframe;
10226 texture.currenttexmatrix = *texmatrix; // requires MATERIALFLAG_CUSTOMSURFACE
10227 texture.offsetmapping = OFFSETMAPPING_OFF;
10228 texture.offsetscale = 1;
10229 texture.specularscalemod = 1;
10230 texture.specularpowermod = 1;
10231 texture.transparentsort = TRANSPARENTSORT_DISTANCE;
10232
10233 R_DrawCustomSurface_Texture(&texture, texmatrix, materialflags, firstvertex, numvertices, firsttriangle, numtriangles, writedepth, prepass, ui);
10234}
void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
Definition gl_rmain.c:10236
#define MATERIALFLAG_CUSTOMSURFACE
@ TRANSPARENTSORT_DISTANCE
Definition r_qshader.h:194
@ OFFSETMAPPING_OFF
Definition r_qshader.h:185
int update_lastrenderframe

Referenced by R_DrawCorona(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLightSprite_TransparentCallback(), R_SkyBox(), and R_SkySphere().

◆ R_DrawCustomSurface_Texture()

void R_DrawCustomSurface_Texture ( texture_t texture,
const matrix4x4_t texmatrix,
int  materialflags,
int  firstvertex,
int  numvertices,
int  firsttriangle,
int  numtriangles,
qbool  writedepth,
qbool  prepass,
qbool  ui 
)

Definition at line 10236 of file gl_rmain.c.

10237{
10238 static msurface_t surface;
10239 const msurface_t *surfacelist = &surface;
10240
10241 // fake enough texture and surface state to render this geometry
10243 surface.num_triangles = numtriangles;
10244 surface.num_firsttriangle = firsttriangle;
10245 surface.num_vertices = numvertices;
10246 surface.num_firstvertex = firstvertex;
10247
10248 // now render it
10254}
static void R_DrawModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
Definition gl_rmain.c:8868
texture_t * R_GetCurrentTexture(texture_t *t)
Definition gl_rmain.c:6585
texture_t * texture
the texture to use on the surface
qbool uselightmaptexture
Definition render.h:743
rtexture_t * lightmaptexture
Definition render.h:739
rtexture_t * deluxemaptexture
Definition render.h:740
texture_t * texture
Definition render.h:738

Referenced by R_DrawCustomSurface(), and R_Model_Sprite_Draw_TransparentCallback().

◆ R_DrawDebugModel()

static void R_DrawDebugModel ( void  )
static

Definition at line 9811 of file gl_rmain.c.

9812{
9814 int j, flagsmask;
9815 const msurface_t *surface;
9816 model_t *model = ent->model;
9817
9818 if (!sv.active && !cls.demoplayback && ent != r_refdef.scene.worldentity)
9819 return;
9820
9821 if (r_showoverdraw.value > 0)
9822 {
9823 float c = r_refdef.view.colorscale * r_showoverdraw.value * 0.125f;
9825 R_SetupShader_Generic_NoTexture(false, false);
9826 GL_DepthTest(false);
9827 GL_DepthMask(false);
9828 GL_DepthRange(0, 1);
9830 for (j = model->submodelsurfaces_start;j < model->submodelsurfaces_end;j++)
9831 {
9833 continue;
9834 surface = model->data_surfaces + j;
9836 if ((rsurface.texture->currentmaterialflags & flagsmask) && surface->num_triangles)
9837 {
9841 GL_Color(c, 0, 0, 1.0f);
9842 else if (ent == r_refdef.scene.worldentity)
9843 GL_Color(c, c, c, 1.0f);
9844 else
9845 GL_Color(0, c, 0, 1.0f);
9848 }
9849 }
9851 }
9852
9854
9855// R_Mesh_ResetTextureState();
9856 R_SetupShader_Generic_NoTexture(false, false);
9857 GL_DepthRange(0, 1);
9859 GL_DepthMask(false);
9861
9863 {
9864 int triangleindex;
9865 int bihleafindex;
9866 qbool cullbox = false;
9867 const q3mbrush_t *brush;
9868 const bih_t *bih = &model->collision_bih;
9869 const bih_leaf_t *bihleaf;
9870 float vertex3f[3][3];
9872 for (bihleafindex = 0, bihleaf = bih->leafs;bihleafindex < bih->numleafs;bihleafindex++, bihleaf++)
9873 {
9874 if (cullbox && R_CullFrustum(bihleaf->mins, bihleaf->maxs))
9875 continue;
9876 switch (bihleaf->type)
9877 {
9878 case BIH_BRUSH:
9879 brush = model->brush.data_brushes + bihleaf->itemindex;
9880 if (brush->colbrushf && brush->colbrushf->numtriangles)
9881 {
9882 GL_Color((bihleafindex & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 5) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 10) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, r_showcollisionbrushes.value);
9883 R_Mesh_PrepareVertices_Generic_Arrays(brush->colbrushf->numpoints, brush->colbrushf->points->v, NULL, NULL);
9884 R_Mesh_Draw(0, brush->colbrushf->numpoints, 0, brush->colbrushf->numtriangles, brush->colbrushf->elements, NULL, 0, NULL, NULL, 0);
9885 }
9886 break;
9888 triangleindex = bihleaf->itemindex;
9889 VectorCopy(model->brush.data_collisionvertex3f + 3*model->brush.data_collisionelement3i[triangleindex*3+0], vertex3f[0]);
9890 VectorCopy(model->brush.data_collisionvertex3f + 3*model->brush.data_collisionelement3i[triangleindex*3+1], vertex3f[1]);
9891 VectorCopy(model->brush.data_collisionvertex3f + 3*model->brush.data_collisionelement3i[triangleindex*3+2], vertex3f[2]);
9892 GL_Color((bihleafindex & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 5) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 10) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, r_showcollisionbrushes.value);
9895 break;
9896 case BIH_RENDERTRIANGLE:
9897 triangleindex = bihleaf->itemindex;
9898 VectorCopy(model->surfmesh.data_vertex3f + 3*model->surfmesh.data_element3i[triangleindex*3+0], vertex3f[0]);
9899 VectorCopy(model->surfmesh.data_vertex3f + 3*model->surfmesh.data_element3i[triangleindex*3+1], vertex3f[1]);
9900 VectorCopy(model->surfmesh.data_vertex3f + 3*model->surfmesh.data_element3i[triangleindex*3+2], vertex3f[2]);
9901 GL_Color((bihleafindex & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 5) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 10) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, r_showcollisionbrushes.value);
9904 break;
9905 }
9906 }
9907 }
9908
9910
9911#ifndef USE_GLES2
9912 if (r_showtris.value > 0 && qglPolygonMode)
9913 {
9915 {
9917 GL_DepthMask(false);
9918 }
9919 else
9920 {
9922 GL_DepthMask(true);
9923 }
9925 for (j = model->submodelsurfaces_start; j < model->submodelsurfaces_end; j++)
9926 {
9928 continue;
9929 surface = model->data_surfaces + j;
9931 if ((rsurface.texture->currentmaterialflags & flagsmask) && surface->num_triangles)
9932 {
9936 else if (ent == r_refdef.scene.worldentity)
9938 else
9942 }
9943 }
9946 }
9947
9948# if 0
9949 // FIXME! implement r_shownormals with just triangles
9950 if (r_shownormals.value != 0 && qglBegin)
9951 {
9952 int l, k;
9953 vec3_t v;
9955 {
9957 GL_DepthMask(false);
9958 }
9959 else
9960 {
9962 GL_DepthMask(true);
9963 }
9964 for (j = model->submodelsurfaces_start; j < model->submodelsurfaces_end; j++)
9965 {
9967 continue;
9968 surface = model->data_surfaces + j;
9970 if ((rsurface.texture->currentmaterialflags & flagsmask) && surface->num_triangles)
9971 {
9975 {
9977 {
9979 GL_Color(0, 0, r_refdef.view.colorscale, 1);
9980 qglVertex3f(v[0], v[1], v[2]);
9983 qglVertex3f(v[0], v[1], v[2]);
9984 }
9985 }
9987 {
9989 {
9991 GL_Color(r_refdef.view.colorscale, 0, 0, 1);
9992 qglVertex3f(v[0], v[1], v[2]);
9995 qglVertex3f(v[0], v[1], v[2]);
9996 }
9997 }
9999 {
10001 {
10003 GL_Color(0, r_refdef.view.colorscale, 0, 1);
10004 qglVertex3f(v[0], v[1], v[2]);
10007 qglVertex3f(v[0], v[1], v[2]);
10008 }
10009 }
10011 {
10013 {
10015 GL_Color(0, 0, r_refdef.view.colorscale, 1);
10016 qglVertex3f(v[0], v[1], v[2]);
10019 qglVertex3f(v[0], v[1], v[2]);
10020 }
10021 }
10022 qglEnd();
10024 }
10025 }
10027 }
10028# endif
10029#endif
10030}
@ BIH_COLLISIONTRIANGLE
Definition bih.h:30
@ BIH_RENDERTRIANGLE
Definition bih.h:31
@ BIH_BRUSH
Definition bih.h:29
void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:7424
void RSurf_DrawBatch(void)
Definition gl_rmain.c:8513
qbool R_CullFrustum(const vec3_t mins, const vec3_t maxs)
Definition gl_rmain.c:3472
#define GL_FRONT_AND_BACK
Definition glquake.h:136
#define GL_FILL
Definition glquake.h:108
#define GL_LINE
Definition glquake.h:107
#define MATERIALFLAG_NOCULLFACE
#define BATCHNEED_NOGAPS
Definition render.h:798
#define BATCHNEED_ARRAY_NORMAL
Definition render.h:791
#define BATCHNEED_ARRAY_VECTOR
Definition render.h:792
#define BATCHNEED_ARRAY_VERTEX
Definition render.h:790
server_t sv
local server
Definition sv_main.c:219
qbool demoplayback
Definition client.h:588
struct q3mbrush_s * data_brushes
int * data_collisionelement3i
float * data_collisionvertex3f
struct colbrushf_s * colbrushf
float colorscale
global RGB color multiplier for rendering
Definition render.h:302
unsigned char * world_surfacevisible
Definition render.h:344
float * batchsvector3f
Definition render.h:681
int batchnumvertices
Definition render.h:675
entity_render_t * entity
Definition render.h:772
float * batchtvector3f
Definition render.h:684
int batchfirstvertex
Definition render.h:674
float * batchvertex3f
Definition render.h:678
float * batchnormal3f
Definition render.h:687
qbool active
false if only a net client
Definition server.h:66
int * data_element3i
float * data_vertex3f
int currentmaterialflags

Referenced by R_DrawModelSurfaces().

◆ R_DrawEntityBBoxes()

static void R_DrawEntityBBoxes ( prvm_prog_t prog)
static

Definition at line 6156 of file gl_rmain.c.

6157{
6158 int i;
6159 prvm_edict_t *edict;
6160 vec3_t center;
6161
6162 if (prog == NULL)
6163 return;
6164
6165 for (i = 0; i < prog->num_edicts; i++)
6166 {
6167 edict = PRVM_EDICT_NUM(i);
6168 if (edict->free)
6169 continue;
6170 // exclude the following for now, as they don't live in world coordinate space and can't be solid:
6171 if (PRVM_gameedictedict(edict, tag_entity) != 0)
6172 continue;
6173 if (prog == SVVM_prog && PRVM_serveredictedict(edict, viewmodelforclient) != 0)
6174 continue;
6175 VectorLerp(edict->priv.server->areamins, 0.5f, edict->priv.server->areamaxs, center);
6177 }
6178}
static void R_DrawEntityBBoxes_Callback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rmain.c:6122
#define VectorLerp(v1, lerp, v2, c)
Definition mathlib.h:119
void R_MeshQueue_AddTransparent(dptransparentsortcategory_t category, const vec3_t center, void(*callback)(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist), const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
Definition meshqueue.c:33
#define PRVM_serveredictedict(ed, fieldname)
Definition progsvm.h:174
#define PRVM_gameedictedict(ed, fieldname)
Definition progsvm.h:162
#define PRVM_EDICT_NUM(n)
Definition progsvm.h:864
#define SVVM_prog
Definition progsvm.h:763
qbool free
Definition progsvm.h:92
union prvm_edict_t::@25 priv
struct edict_engineprivate_s * server
Definition progsvm.h:105
int num_edicts
Definition progsvm.h:668

Referenced by R_RenderScene().

◆ R_DrawEntityBBoxes_Callback()

static void R_DrawEntityBBoxes_Callback ( const entity_render_t ent,
const rtlight_t rtlight,
int  numsurfaces,
int surfacelist 
)
static

Definition at line 6122 of file gl_rmain.c.

6123{
6124 // hacky overloading of the parameters
6125 prvm_prog_t *prog = (prvm_prog_t *)rtlight;
6126 int i;
6127 float color[4];
6128 prvm_edict_t *edict;
6129
6131 R_SetupShader_Generic_NoTexture(false, false);
6132
6133 for (i = 0;i < numsurfaces;i++)
6134 {
6135 edict = PRVM_EDICT_NUM(surfacelist[i]);
6136 switch ((int)PRVM_serveredictfloat(edict, solid))
6137 {
6138 case SOLID_NOT: Vector4Set(color, 1, 1, 1, 0.05);break;
6139 case SOLID_TRIGGER: Vector4Set(color, 1, 0, 1, 0.10);break;
6140 case SOLID_BBOX: Vector4Set(color, 0, 1, 0, 0.10);break;
6141 case SOLID_SLIDEBOX: Vector4Set(color, 1, 0, 0, 0.10);break;
6142 case SOLID_BSP: Vector4Set(color, 0, 0, 1, 0.05);break;
6143 case SOLID_CORPSE: Vector4Set(color, 1, 0.5, 0, 0.05);break;
6144 default: Vector4Set(color, 0, 0, 0, 0.50);break;
6145 }
6146 if (prog == CLVM_prog)
6148 else
6149 color[3] *= r_showbboxes.value;
6150 color[3] = bound(0, color[3], 1);
6152 R_DrawBBoxMesh(edict->priv.server->areamins, edict->priv.server->areamaxs, color[0], color[1], color[2], color[3]);
6153 }
6154}
static void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, float ca)
Definition gl_rmain.c:6070
#define CLVM_prog
Definition progsvm.h:764
#define PRVM_serveredictfloat(ed, fieldname)
Definition progsvm.h:171
#define SOLID_BBOX
touch on edge, block
Definition server.h:335
#define SOLID_SLIDEBOX
touch on edge, but not an onground
Definition server.h:336
#define SOLID_CORPSE
same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
Definition server.h:339
#define SOLID_NOT
no interaction with other objects
Definition server.h:333
#define SOLID_TRIGGER
touch on edge, but not blocking
Definition server.h:334
#define SOLID_BSP
bsp clip, touch on edge, block
Definition server.h:337
vec3 color

Referenced by R_DrawEntityBBoxes().

◆ R_DrawLoc_Callback()

static void R_DrawLoc_Callback ( const entity_render_t ent,
const rtlight_t rtlight,
int  numsurfaces,
int surfacelist 
)
static

Definition at line 9114 of file gl_rmain.c.

9115{
9116 int i, j;
9117 cl_locnode_t *loc = (cl_locnode_t *)ent;
9118 vec3_t mins, size;
9119 float vertex3f[6*4*3];
9122 GL_DepthMask(false);
9123 GL_DepthRange(0, 1);
9125 GL_DepthTest(true);
9128
9129// R_Mesh_ResetTextureState();
9130
9131 i = surfacelist[0];
9132 GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_refdef.view.colorscale,
9133 ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_refdef.view.colorscale,
9134 ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_refdef.view.colorscale,
9135 surfacelist[0] < 0 ? 0.5f : 0.125f);
9136
9137 if (VectorCompare(loc->mins, loc->maxs))
9138 {
9139 VectorSet(size, 2, 2, 2);
9140 VectorMA(loc->mins, -0.5f, size, mins);
9141 }
9142 else
9143 {
9144 VectorCopy(loc->mins, mins);
9145 VectorSubtract(loc->maxs, loc->mins, size);
9146 }
9147
9148 for (i = 0;i < 6*4*3;)
9149 for (j = 0;j < 3;j++, i++)
9150 vertex3f[i] = mins[j] + size[j] * locboxvertex3f[i];
9151
9153 R_SetupShader_Generic_NoTexture(false, false);
9154 R_Mesh_Draw(0, 6*4, 0, 6*2, NULL, NULL, 0, locboxelements, NULL, 0);
9155}
unsigned short locboxelements[6 *2 *3]
Definition gl_rmain.c:9104
float locboxvertex3f[6 *4 *3]
Definition gl_rmain.c:9094
#define VectorCompare(a, b)
Definition mathlib.h:112

Referenced by R_DrawLocs().

◆ R_DrawLocs()

void R_DrawLocs ( void  )
static

Definition at line 9157 of file gl_rmain.c.

9158{
9159 int index;
9161 vec3_t center;
9163 for (loc = cl.locnodes, index = 0;loc;loc = loc->next, index++)
9164 {
9165 VectorLerp(loc->mins, 0.5f, loc->maxs, center);
9167 }
9168}
cl_locnode_t * CL_Locs_FindNearest(const vec3_t point)
Definition cl_main.c:2198
static void R_DrawLoc_Callback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rmain.c:9114
vec3_t movement_origin
Definition client.h:810
cl_locnode_t * locnodes
Definition client.h:1126

Referenced by R_RenderScene().

◆ R_DrawModelDecals()

static void R_DrawModelDecals ( void  )
static

Definition at line 9775 of file gl_rmain.c.

9776{
9777 int i, numdecals;
9778
9779 // fade faster when there are too many decals
9781 for (i = 0;i < r_refdef.scene.numentities;i++)
9783
9785 for (i = 0;i < r_refdef.scene.numentities;i++)
9788
9790
9792 for (i = 0;i < r_refdef.scene.numentities;i++)
9794
9795 r_refdef.stats[r_stat_totaldecals] += numdecals;
9796
9798 return;
9799
9801
9802 for (i = 0;i < r_refdef.scene.numentities;i++)
9803 {
9805 continue;
9808 }
9809}
static void R_DecalSystem_ApplySplatEntitiesQueue(void)
Definition gl_rmain.c:9565
static void R_DrawModelDecals_Entity(entity_render_t *ent)
Definition gl_rmain.c:9645
cvar_t r_drawdecals
static void R_DrawModelDecals_FadeEntity(entity_render_t *ent)
Definition gl_rmain.c:9576
@ r_stat_totaldecals
Definition r_stats.h:23

Referenced by R_RenderScene().

◆ R_DrawModelDecals_Entity()

static void R_DrawModelDecals_Entity ( entity_render_t ent)
static

Definition at line 9645 of file gl_rmain.c.

9646{
9647 int i;
9648 decalsystem_t *decalsystem = &ent->decalsystem;
9649 int numdecals;
9651 float faderate;
9652 float alpha;
9653 float *v3f;
9654 float *c4f;
9655 float *t2f;
9656 const int *e;
9658 int numtris = 0;
9659
9660 numdecals = decalsystem->numdecals;
9661 if (!numdecals)
9662 return;
9663
9665 return;
9666
9667 if (ent->model != decalsystem->model || ent->alpha < 1 || (ent->flags & RENDER_ADDITIVE))
9668 {
9669 R_DecalSystem_Reset(decalsystem);
9670 return;
9671 }
9672
9673 // if the model is static it doesn't matter what value we give for
9674 // wantnormals and wanttangents, so this logic uses only rules applicable
9675 // to a model, knowing that they are meaningless otherwise
9676 RSurf_ActiveModelEntity(ent, false, false, false);
9677
9678 decalsystem->lastupdatetime = r_refdef.scene.time;
9679
9680 faderate = 1.0f / max(0.001f, cl_decals_fadetime.value);
9681
9682 // update vertex positions for animated models
9683 v3f = decalsystem->vertex3f;
9684 c4f = decalsystem->color4f;
9685 t2f = decalsystem->texcoord2f;
9686 for (i = 0, decal = decalsystem->decals;i < numdecals;i++, decal++)
9687 {
9688 if (!decal->color4f[0][3])
9689 continue;
9690
9691 if (surfacevisible && !surfacevisible[decal->surfaceindex])
9692 continue;
9693
9694 // skip backfaces
9695 if (decal->triangleindex < 0 && DotProduct(r_refdef.view.origin, decal->plane) < decal->plane[3])
9696 continue;
9697
9698 // update color values for fading decals
9699 if (decal->lived >= cl_decals_time.value)
9700 alpha = 1 - faderate * (decal->lived - cl_decals_time.value);
9701 else
9702 alpha = 1.0f;
9703
9704 c4f[ 0] = decal->color4f[0][0] * alpha;
9705 c4f[ 1] = decal->color4f[0][1] * alpha;
9706 c4f[ 2] = decal->color4f[0][2] * alpha;
9707 c4f[ 3] = 1;
9708 c4f[ 4] = decal->color4f[1][0] * alpha;
9709 c4f[ 5] = decal->color4f[1][1] * alpha;
9710 c4f[ 6] = decal->color4f[1][2] * alpha;
9711 c4f[ 7] = 1;
9712 c4f[ 8] = decal->color4f[2][0] * alpha;
9713 c4f[ 9] = decal->color4f[2][1] * alpha;
9714 c4f[10] = decal->color4f[2][2] * alpha;
9715 c4f[11] = 1;
9716
9717 t2f[0] = decal->texcoord2f[0][0];
9718 t2f[1] = decal->texcoord2f[0][1];
9719 t2f[2] = decal->texcoord2f[1][0];
9720 t2f[3] = decal->texcoord2f[1][1];
9721 t2f[4] = decal->texcoord2f[2][0];
9722 t2f[5] = decal->texcoord2f[2][1];
9723
9724 // update vertex positions for animated models
9725 if (decal->triangleindex >= 0 && decal->triangleindex < rsurface.modelnumtriangles)
9726 {
9727 e = rsurface.modelelement3i + 3*decal->triangleindex;
9729 VectorCopy(rsurface.modelvertex3f + 3*e[1], v3f + 3);
9730 VectorCopy(rsurface.modelvertex3f + 3*e[2], v3f + 6);
9731 }
9732 else
9733 {
9734 VectorCopy(decal->vertex3f[0], v3f);
9735 VectorCopy(decal->vertex3f[1], v3f + 3);
9736 VectorCopy(decal->vertex3f[2], v3f + 6);
9737 }
9738
9739 if (r_refdef.fogenabled)
9740 {
9743 alpha = RSurf_FogVertex(v3f + 3);
9744 VectorScale(c4f + 4, alpha, c4f + 4);
9745 alpha = RSurf_FogVertex(v3f + 6);
9746 VectorScale(c4f + 8, alpha, c4f + 8);
9747 }
9748
9749 v3f += 9;
9750 c4f += 12;
9751 t2f += 6;
9752 numtris++;
9753 }
9754
9755 if (numtris > 0)
9756 {
9757 r_refdef.stats[r_stat_drawndecals] += numtris;
9758
9759 // now render the decals all at once
9760 // (this assumes they all use one particle font texture!)
9761 RSurf_ActiveCustomEntity(&rsurface.matrix, &rsurface.inversematrix, rsurface.ent_flags, ent->shadertime, 1, 1, 1, 1, numdecals*3, decalsystem->vertex3f, decalsystem->texcoord2f, NULL, NULL, NULL, decalsystem->color4f, numtris, decalsystem->element3i, decalsystem->element3s, false, false);
9762// R_Mesh_ResetTextureState();
9763 R_Mesh_PrepareVertices_Generic_Arrays(numtris * 3, decalsystem->vertex3f, decalsystem->color4f, decalsystem->texcoord2f);
9764 GL_DepthMask(false);
9765 GL_DepthRange(0, 1);
9767 GL_DepthTest(true);
9770 R_SetupShader_Generic(decalskinframe->base, false, false, false);
9771 R_Mesh_Draw(0, numtris * 3, 0, numtris, decalsystem->element3i, NULL, 0, decalsystem->element3s, NULL, 0);
9772 }
9773}
cvar_t cl_decals_fadetime
cvar_t cl_decals_time
skinframe_t * decalskinframe
void RSurf_ActiveCustomEntity(const matrix4x4_t *matrix, const matrix4x4_t *inversematrix, int entflags, double shadertime, float r, float g, float b, float a, int numvertices, const float *vertex3f, const float *texcoord2f, const float *normal3f, const float *svector3f, const float *tvector3f, const float *color4f, int numtriangles, const int *element3i, const unsigned short *element3s, qbool wantnormals, qbool wanttangents)
Definition gl_rmain.c:7182
@ r_stat_drawndecals
Definition r_stats.h:22
double lastupdatetime
Definition client.h:58
double shadertime
Definition client.h:367
double time
(client gameworld) time for rendering time based effects
Definition render.h:357
float basepolygonfactor
Definition render.h:735
matrix4x4_t matrix
Definition render.h:724
int modelnumtriangles
Definition render.h:662
float basepolygonoffset
Definition render.h:736
struct rtexture_s * base
Definition r_textures.h:129

Referenced by R_DrawModelDecals().

◆ R_DrawModelDecals_FadeEntity()

static void R_DrawModelDecals_FadeEntity ( entity_render_t ent)
static

Definition at line 9576 of file gl_rmain.c.

9577{
9578 int i;
9579 decalsystem_t *decalsystem = &ent->decalsystem;
9580 int numdecals;
9581 unsigned int killsequence;
9583 float frametime;
9584 float lifetime;
9585
9586 if (!decalsystem->numdecals)
9587 return;
9588
9590 return;
9591
9592 if (ent->model != decalsystem->model || ent->alpha < 1 || (ent->flags & RENDER_ADDITIVE))
9593 {
9594 R_DecalSystem_Reset(decalsystem);
9595 return;
9596 }
9597
9600
9601 if (decalsystem->lastupdatetime)
9602 frametime = (r_refdef.scene.time - decalsystem->lastupdatetime);
9603 else
9604 frametime = 0;
9605 decalsystem->lastupdatetime = r_refdef.scene.time;
9606 numdecals = decalsystem->numdecals;
9607
9608 for (i = 0, decal = decalsystem->decals;i < numdecals;i++, decal++)
9609 {
9610 if (decal->color4f[0][3])
9611 {
9612 decal->lived += frametime;
9613 if (killsequence > decal->decalsequence || decal->lived >= lifetime)
9614 {
9615 memset(decal, 0, sizeof(*decal));
9616 if (decalsystem->freedecal > i)
9617 decalsystem->freedecal = i;
9618 }
9619 }
9620 }
9621 decal = decalsystem->decals;
9622 while (numdecals > 0 && !decal[numdecals-1].color4f[0][3])
9623 numdecals--;
9624
9625 // collapse the array by shuffling the tail decals into the gaps
9626 for (;;)
9627 {
9628 while (decalsystem->freedecal < numdecals && decal[decalsystem->freedecal].color4f[0][3])
9629 decalsystem->freedecal++;
9630 if (decalsystem->freedecal == numdecals)
9631 break;
9632 decal[decalsystem->freedecal] = decal[--numdecals];
9633 }
9634
9635 decalsystem->numdecals = numdecals;
9636
9637 if (numdecals <= 0)
9638 {
9639 // if there are no decals left, reset decalsystem
9640 R_DecalSystem_Reset(decalsystem);
9641 }
9642}
cvar_t cl_decals_max

Referenced by R_DrawModelDecals().

◆ R_DrawModels()

static void R_DrawModels ( void  )
static

Definition at line 4086 of file gl_rmain.c.

4087{
4088 int i;
4089 entity_render_t *ent;
4090
4091 for (i = 0;i < r_refdef.scene.numentities;i++)
4092 {
4094 continue;
4095 ent = r_refdef.scene.entities[i];
4097
4098 if (ent->model && ent->model->Draw != NULL)
4099 ent->model->Draw(ent);
4100 else
4101 R_DrawNoModel(ent);
4102 }
4103}
static void R_DrawNoModel(entity_render_t *ent)
Definition gl_rmain.c:6279
@ r_stat_entities
Definition r_stats.h:12

Referenced by R_RenderScene().

◆ R_DrawModelsAddWaterPlanes()

static void R_DrawModelsAddWaterPlanes ( void  )
static

Definition at line 4135 of file gl_rmain.c.

4136{
4137 int i;
4138 entity_render_t *ent;
4139
4140 for (i = 0;i < r_refdef.scene.numentities;i++)
4141 {
4143 continue;
4144 ent = r_refdef.scene.entities[i];
4145 if (ent->model && ent->model->DrawAddWaterPlanes != NULL)
4146 ent->model->DrawAddWaterPlanes(ent);
4147 }
4148}
void(* DrawAddWaterPlanes)(struct entity_render_s *ent)

Referenced by R_RenderWaterPlanes().

◆ R_DrawModelsDebug()

static void R_DrawModelsDebug ( void  )
static

Definition at line 4120 of file gl_rmain.c.

4121{
4122 int i;
4123 entity_render_t *ent;
4124
4125 for (i = 0;i < r_refdef.scene.numentities;i++)
4126 {
4128 continue;
4129 ent = r_refdef.scene.entities[i];
4130 if (ent->model && ent->model->DrawDebug != NULL)
4131 ent->model->DrawDebug(ent);
4132 }
4133}
void(* DrawDebug)(struct entity_render_s *ent)

Referenced by R_RenderScene().

◆ R_DrawModelsDepth()

static void R_DrawModelsDepth ( void  )
static

Definition at line 4105 of file gl_rmain.c.

4106{
4107 int i;
4108 entity_render_t *ent;
4109
4110 for (i = 0;i < r_refdef.scene.numentities;i++)
4111 {
4113 continue;
4114 ent = r_refdef.scene.entities[i];
4115 if (ent->model && ent->model->DrawDepth != NULL)
4116 ent->model->DrawDepth(ent);
4117 }
4118}
void(* DrawDepth)(struct entity_render_s *ent)

Referenced by R_RenderScene().

◆ R_DrawModelSurfaces()

void R_DrawModelSurfaces ( entity_render_t ent,
qbool  skysurfaces,
qbool  writedepth,
qbool  depthonly,
qbool  debug,
qbool  prepass,
qbool  ui 
)

Definition at line 10034 of file gl_rmain.c.

10035{
10036 int i, j, flagsmask;
10037 model_t *model = ent->model;
10039 unsigned char *update;
10040 int numsurfacelist = 0;
10041 if (model == NULL)
10042 return;
10043
10044 if (r_maxsurfacelist < model->num_surfaces)
10045 {
10047 if (r_surfacelist)
10050 }
10051
10053 RSurf_ActiveModelEntity(ent, false, false, false);
10054 else if (prepass)
10055 RSurf_ActiveModelEntity(ent, true, true, true);
10056 else if (depthonly)
10057 RSurf_ActiveModelEntity(ent, model->wantnormals, model->wanttangents, false);
10058 else
10059 RSurf_ActiveModelEntity(ent, true, true, false);
10060
10061 surfaces = model->data_surfaces;
10063
10065
10066 if (debug)
10067 {
10069 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10070 return;
10071 }
10072
10073 // check if this is an empty model
10074 if (model->submodelsurfaces_start >= model->submodelsurfaces_end)
10075 return;
10076
10082 numsurfacelist = 0;
10083
10084 // add visible surfaces to draw list
10085 if (ent == r_refdef.scene.worldentity)
10086 {
10087 // for the world entity, check surfacevisible
10088 for (i = model->submodelsurfaces_start;i < model->submodelsurfaces_end;i++)
10089 {
10090 j = model->modelsurfaces_sorted[i];
10093 }
10094
10095 // don't do anything if there were no surfaces added (none of the world entity is visible)
10096 if (!numsurfacelist)
10097 {
10098 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10099 return;
10100 }
10101 }
10102 else if (ui)
10103 {
10104 // for ui we have to preserve the order of surfaces (not using modelsurfaces_sorted)
10105 for (i = model->submodelsurfaces_start; i < model->submodelsurfaces_end; i++)
10107 }
10108 else
10109 {
10110 // add all surfaces
10111 for (i = model->submodelsurfaces_start; i < model->submodelsurfaces_end; i++)
10113 }
10114
10115 /*
10116 * Mark lightmaps as dirty if their lightstyle's value changed. We do this by
10117 * using style chains because most styles do not change on most frames, and most
10118 * surfaces do not have styles on them. Mods like Arcane Dimensions (e.g. ad_necrokeep)
10119 * break this rule and animate most surfaces.
10120 */
10122 {
10124
10125 // For each lightstyle, check if its value changed and mark the lightmaps as dirty if so
10126 for (i = 0, style = model->brushq1.data_lightstyleinfo; i < model->brushq1.num_lightstyles; i++, style++)
10127 {
10128 if (style->value != r_refdef.scene.lightstylevalue[style->style])
10129 {
10130 int* list = style->surfacelist;
10131 style->value = r_refdef.scene.lightstylevalue[style->style];
10132 // Value changed - mark the surfaces belonging to this style chain as dirty
10133 for (j = 0; j < style->numsurfaces; j++)
10134 update[list[j]] = true;
10135 }
10136 }
10137 // Now check if update flags are set on any surfaces that are visible
10139 {
10140 /*
10141 * We can do less frequent texture uploads (approximately 10hz for animated
10142 * lightstyles) by rebuilding lightmaps on surfaces that are not currently visible.
10143 * For optimal efficiency, this includes the submodels of the worldmodel, so we
10144 * use model->num_surfaces, not nummodelsurfaces.
10145 */
10146 for (i = 0; i < model->num_surfaces;i++)
10147 if (update[i])
10149 }
10150 else
10151 {
10152 for (i = 0; i < numsurfacelist; i++)
10155 }
10156 }
10157
10159
10160 // add to stats if desired
10162 {
10164 for (j = 0;j < numsurfacelist;j++)
10166 }
10167
10168 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10169}
int r_maxsurfacelist
Definition gl_rmain.c:10032
static void R_QueueModelSurfaceList(entity_render_t *ent, int numsurfaces, const msurface_t **surfacelist, int flagsmask, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
Definition gl_rmain.c:9048
const msurface_t ** r_surfacelist
Definition gl_rmain.c:10033
static void R_DrawDebugModel(void)
Definition gl_rmain.c:9811
void R_BuildLightMap(const entity_render_t *ent, msurface_t *surface, int combine)
Definition gl_rsurf.c:50
@ r_stat_entities_triangles
Definition r_stats.h:14
@ r_stat_entities_surfaces
Definition r_stats.h:13
model_brush_lightstyleinfo_t * data_lightstyleinfo
Definition model_q1bsp.h:37
unsigned char * lightmapupdateflags
Definition model_q1bsp.h:40
int * modelsurfaces_sorted
surface indices of model in an optimal draw order (submodelindex -> texture -> lightmap -> index)
qbool wanttangents
model_brushq1_t brushq1
int num_surfaces
qbool wantnormals
int num_triangles
range of triangles and vertices in model->surfmesh
float lightmapintensity
Definition render.h:392
unsigned short lightstylevalue[MAX_LIGHTSTYLES]
8.8 fraction of base light value
Definition render.h:385
const rtlight_t * rtlight
Definition render.h:753

Referenced by DrawQ_FlushUI(), R_Mod_Draw(), R_Mod_DrawDebug(), R_Mod_DrawDepth(), R_Mod_DrawPrepass(), and R_Mod_DrawSky().

◆ R_DrawModelTextureSurfaceList()

static void R_DrawModelTextureSurfaceList ( int  texturenumsurfaces,
const msurface_t **  texturesurfacelist,
qbool  writedepth,
qbool  prepass,
qbool  ui 
)
static

Definition at line 8868 of file gl_rmain.c.

8869{
8873 {
8875 return;
8876 }
8877 switch (vid.renderpath)
8878 {
8879 case RENDERPATH_GL32:
8880 case RENDERPATH_GLES2:
8882 break;
8883 }
8885}
static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
Definition gl_rmain.c:8722
void RSurf_SetupDepthAndCulling(bool ui)
Definition gl_rmain.c:8612
static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth)
Definition gl_rmain.c:8782
qbool showdebug
Definition render.h:314

Referenced by R_DrawCustomSurface_Texture(), R_DrawSurface_TransparentCallback(), and R_ProcessModelTextureSurfaceList().

◆ R_DrawNoModel()

void R_DrawNoModel ( entity_render_t ent)
static

Definition at line 6279 of file gl_rmain.c.

6280{
6281 vec3_t org;
6283 if ((ent->flags & RENDER_ADDITIVE) || (ent->alpha < 1))
6285 else
6287}
static void R_DrawNoModel_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rmain.c:6224
void Matrix4x4_OriginFromMatrix(const matrix4x4_t *in, float *out)
Definition matrixlib.c:1792
@ TRANSPARENTSORT_HUD
Definition r_qshader.h:195
matrix4x4_t matrix
Definition client.h:333

Referenced by R_DrawModels().

◆ R_DrawNoModel_TransparentCallback()

static void R_DrawNoModel_TransparentCallback ( const entity_render_t ent,
const rtlight_t rtlight,
int  numsurfaces,
int surfacelist 
)
static

Definition at line 6224 of file gl_rmain.c.

6225{
6226 int i;
6227 float f1, f2, *c;
6228 float color4f[6*4];
6229
6230 RSurf_ActiveCustomEntity(&ent->matrix, &ent->inversematrix, ent->flags, ent->shadertime, ent->colormod[0], ent->colormod[1], ent->colormod[2], ent->alpha, 6, nomodelvertex3f, NULL, NULL, NULL, NULL, nomodelcolor4f, 8, nomodelelement3i, nomodelelement3s, false, false);
6231
6232 // this is only called once per entity so numsurfaces is always 1, and
6233 // surfacelist is always {0}, so this code does not handle batches
6234
6236 {
6238 GL_DepthMask(false);
6239 }
6240 else if (ent->alpha < 1)
6241 {
6243 GL_DepthMask(false);
6244 }
6245 else
6246 {
6248 GL_DepthMask(true);
6249 }
6250 GL_DepthRange(0, (rsurface.ent_flags & RENDER_VIEWMODEL) ? 0.0625 : 1);
6254 memcpy(color4f, nomodelcolor4f, sizeof(float[6*4]));
6255 for (i = 0, c = color4f;i < 6;i++, c += 4)
6256 {
6257 c[0] *= ent->render_fullbright[0] * r_refdef.view.colorscale;
6258 c[1] *= ent->render_fullbright[1] * r_refdef.view.colorscale;
6259 c[2] *= ent->render_fullbright[2] * r_refdef.view.colorscale;
6260 c[3] *= ent->alpha;
6261 }
6262 if (r_refdef.fogenabled)
6263 {
6264 for (i = 0, c = color4f;i < 6;i++, c += 4)
6265 {
6267 f2 = 1 - f1;
6268 c[0] = (c[0] * f1 + r_refdef.fogcolor[0] * f2);
6269 c[1] = (c[1] * f1 + r_refdef.fogcolor[1] * f2);
6270 c[2] = (c[2] * f1 + r_refdef.fogcolor[2] * f2);
6271 }
6272 }
6273// R_Mesh_ResetTextureState();
6274 R_SetupShader_Generic_NoTexture(false, false);
6277}
static const int nomodelelement3i[24]
Definition gl_rmain.c:6180
static const float nomodelvertex3f[6 *3]
Definition gl_rmain.c:6204
static const unsigned short nomodelelement3s[24]
Definition gl_rmain.c:6192
static const float nomodelcolor4f[6 *4]
Definition gl_rmain.c:6214
#define RENDER_VIEWMODEL
Definition protocol.h:359
#define RENDER_DOUBLESIDED
Definition protocol.h:372
float render_fullbright[3]
Definition client.h:413
matrix4x4_t inversematrix
Definition client.h:335
float colormod[3]
Definition client.h:360

Referenced by R_DrawNoModel().

◆ R_DrawSurface_TransparentCallback()

static void R_DrawSurface_TransparentCallback ( const entity_render_t ent,
const rtlight_t rtlight,
int  numsurfaces,
int surfacelist 
)
static

Definition at line 8887 of file gl_rmain.c.

8888{
8889 int i, j;
8892 const msurface_t *surface;
8894
8895 RSurf_ActiveModelEntity(ent, true, true, false);
8896
8898 {
8899 qbool setup = false;
8900 for (i = 0;i < numsurfaces;i = j)
8901 {
8902 j = i + 1;
8903 surface = rsurface.modelsurfaces + surfacelist[i];
8909 // scan ahead until we find a different texture
8910 endsurface = min(i + 1024, numsurfaces);
8913 for (;j < endsurface;j++)
8914 {
8915 surface = rsurface.modelsurfaces + surfacelist[j];
8916 if (texture != surface->texture)
8917 break;
8919 }
8921 continue;
8922 // render the range of surfaces as depth
8923 if (!setup)
8924 {
8925 setup = true;
8926 GL_ColorMask(0,0,0,0);
8927 GL_Color(1,1,1,1);
8928 GL_DepthTest(true);
8930 GL_DepthMask(true);
8931// R_Mesh_ResetTextureState();
8932 }
8938 }
8939 if (setup)
8941 }
8942
8943 for (i = 0;i < numsurfaces;i = j)
8944 {
8945 j = i + 1;
8946 surface = rsurface.modelsurfaces + surfacelist[i];
8949 // scan ahead until we find a different texture
8953 rsurface.lightmaptexture = surface->lightmaptexture;
8954 rsurface.deluxemaptexture = surface->deluxemaptexture;
8955 rsurface.uselightmaptexture = surface->lightmaptexture != NULL;
8956 for (;j < endsurface;j++)
8957 {
8958 surface = rsurface.modelsurfaces + surfacelist[j];
8959 if (texture != surface->texture || rsurface.lightmaptexture != surface->lightmaptexture)
8960 break;
8962 }
8963 // render the range of surfaces
8965 }
8966 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
8967}
void R_Mesh_PrepareVertices_Vertex3f(int numvertices, const float *vertex3f, const r_meshbuffer_t *vertexbuffer, int bufferoffset)
void GL_ColorMask(int r, int g, int b, int a)
void R_SetupShader_DepthOrShadow(qbool notrippy, qbool depthrgb, qbool skeletal)
Definition gl_rmain.c:1492
#define MESHQUEUE_TRANSPARENT_BATCHSIZE
Definition meshqueue.h:6
#define MATERIALFLAG_TRANSDEPTH
#define BATCHNEED_ALLOWMULTIDRAW
Definition render.h:800
int colormask[4]
which color components to allow (for anaglyph glasses)
Definition render.h:299
int batchvertex3f_bufferoffset
Definition render.h:680
const msurface_t * modelsurfaces
Definition render.h:663
const r_meshbuffer_t * batchvertex3f_vertexbuffer
Definition render.h:679
float * batchskeletaltransform3x4
Definition render.h:712

Referenced by R_ProcessTransparentTextureSurfaceList().

◆ R_DrawTextureSurfaceList_DepthOnly()

◆ R_DrawTextureSurfaceList_GL20()

static void R_DrawTextureSurfaceList_GL20 ( int  texturenumsurfaces,
const msurface_t **  texturesurfacelist,
qbool  writedepth,
qbool  prepass,
qbool  ui 
)
static

Definition at line 8722 of file gl_rmain.c.

8723{
8725 return;
8726 if (prepass)
8727 {
8728 // render screenspace normalmap to texture
8729 GL_DepthMask(true);
8732 return;
8733 }
8734
8735 // bind lightmap texture
8736
8737 // water/refraction/reflection/camera surfaces have to be handled specially
8739 {
8740 int start, end, startplaneindex;
8741 for (start = 0;start < texturenumsurfaces;start = end)
8742 {
8744 if(startplaneindex < 0)
8745 {
8746 // this happens if the plane e.g. got backface culled and thus didn't get a water plane. We can just ignore this.
8747 // Con_Printf("No matching water plane for surface with material flags 0x%08x - PLEASE DEBUG THIS\n", rsurface.texture->currentmaterialflags);
8748 end = start + 1;
8749 continue;
8750 }
8751 for (end = start + 1;end < texturenumsurfaces && startplaneindex == RSurf_FindWaterPlaneForSurface(texturesurfacelist[end]);end++)
8752 ;
8753 // now that we have a batch using the same planeindex, render it
8755 {
8756 // render water or distortion background
8757 GL_DepthMask(true);
8760 // blend surface on top
8761 GL_DepthMask(false);
8764 }
8766 {
8767 // render surface with reflection texture as input
8771 }
8772 }
8773 return;
8774 }
8775
8776 // render surface batch normally
8780}
static int RSurf_FindWaterPlaneForSurface(const msurface_t *surface)
Definition gl_rmain.c:8572
void R_SetupShader_Surface(const float rtlightambient[3], const float rtlightdiffuse[3], const float rtlightspecular[3], rsurfacepass_t rsurfacepass, int texturenumsurfaces, const msurface_t **texturesurfacelist, void *surfacewaterplane, qbool notrippy, qbool ui)
Definition gl_rmain.c:1562
vec3_t vec3_origin
Definition mathlib.c:26
#define MATERIALFLAG_CAMERA
@ RSURFPASS_BACKGROUND
Definition render.h:810
@ RSURFPASS_BASE
Definition render.h:809
@ RSURFPASS_DEFERREDGEOMETRY
Definition render.h:812
r_waterstate_waterplane_t waterplanes[MAX_WATERPLANES]
Definition render.h:874

Referenced by R_DrawModelTextureSurfaceList().

◆ R_DrawTextureSurfaceList_ShowSurfaces()

static void R_DrawTextureSurfaceList_ShowSurfaces ( int  texturenumsurfaces,
const msurface_t **  texturesurfacelist,
qbool  writedepth 
)
static

Definition at line 8782 of file gl_rmain.c.

8783{
8784 int vi;
8785 int j;
8787 int k;
8788 const msurface_t *surface;
8789 float surfacecolor4f[4];
8790 float c[4];
8792
8793// R_Mesh_ResetTextureState();
8794 R_SetupShader_Generic_NoTexture(false, false);
8795
8798
8799 switch (r_showsurfaces.integer)
8800 {
8801 case 1:
8802 default:
8804 vi = 0;
8806 {
8808 k = (int)(((size_t)surface) / sizeof(msurface_t));
8809 Vector4Set(surfacecolor4f, (k & 0xF) * (1.0f / 16.0f), (k & 0xF0) * (1.0f / 256.0f), (k & 0xF00) * (1.0f / 4096.0f), 1);
8810 for (j = 0;j < surface->num_vertices;j++)
8811 {
8813 vi++;
8814 }
8815 }
8816 break;
8817 case 3:
8818 if(t && t->currentskinframe)
8819 {
8820 Vector4Copy(t->currentskinframe->avgcolor, c);
8821 c[3] *= t->currentalpha;
8822 }
8823 else
8824 {
8825 Vector4Set(c, 1, 0, 1, 1);
8826 }
8827 if (t && (t->pantstexture || t->shirttexture))
8828 {
8830 }
8833 c[3] *= r_wateralpha.value;
8835 vi = 0;
8837 {
8839 {
8841 for (j = 0;j < surface->num_vertices;j++)
8842 {
8843 float *ptr = rsurface.batchlightmapcolor4f + 4 * vi;
8844 Vector4Multiply(ptr, c, ptr);
8845 vi++;
8846 }
8847 }
8848 }
8849 else
8850 {
8852 {
8854 for (j = 0;j < surface->num_vertices;j++)
8855 {
8856 float *ptr = rsurface.batchlightmapcolor4f + 4 * vi;
8857 Vector4Copy(c, ptr);
8858 vi++;
8859 }
8860 }
8861 }
8862 break;
8863 }
8866}
#define Vector4Copy(a, b)
Definition mathlib.h:83
#define Vector4Multiply(a, b, c)
Definition mathlib.h:90
#define MATERIALFLAG_WATERALPHA
Definition model_brush.h:85
#define BATCHNEED_ARRAY_VERTEXCOLOR
Definition render.h:794
#define BATCHNEED_ALWAYSCOPY
Definition render.h:799
float * modellightmapcolor4f
Definition render.h:639
float * batchtexcoordtexture2f
Definition render.h:693
float * batchlightmapcolor4f
Definition render.h:690
float render_colormap_pants[3]
float render_colormap_shirt[3]
struct rtexture_s * shirttexture
struct rtexture_s * pantstexture
float currentalpha
struct skinframe_s * currentskinframe

Referenced by R_DrawModelTextureSurfaceList().

◆ R_DrawTextureSurfaceList_Sky()

static void R_DrawTextureSurfaceList_Sky ( int  texturenumsurfaces,
const msurface_t **  texturesurfacelist 
)
static

Definition at line 8623 of file gl_rmain.c.

8624{
8625 int j;
8626 const float *v;
8627 float p[3], mins[3], maxs[3];
8628 int scissor[4];
8629 // transparent sky would be ridiculous
8631 return;
8632 R_SetupShader_Generic_NoTexture(false, false);
8633 skyrenderlater = true;
8635 GL_DepthMask(true);
8636
8637 // add the vertices of the surfaces to a world bounding box so we can scissor the sky render later
8639 {
8642 {
8644 if (j > 0)
8645 {
8646 if (mins[0] > p[0]) mins[0] = p[0];
8647 if (mins[1] > p[1]) mins[1] = p[1];
8648 if (mins[2] > p[2]) mins[2] = p[2];
8649 if (maxs[0] < p[0]) maxs[0] = p[0];
8650 if (maxs[1] < p[1]) maxs[1] = p[1];
8651 if (maxs[2] < p[2]) maxs[2] = p[2];
8652 }
8653 else
8654 {
8655 VectorCopy(p, mins);
8656 VectorCopy(p, maxs);
8657 }
8658 }
8659 if (!R_ScissorForBBox(mins, maxs, scissor))
8660 {
8661 if (skyscissor[2])
8662 {
8663 if (skyscissor[0] > scissor[0])
8664 {
8665 skyscissor[2] += skyscissor[0] - scissor[0];
8666 skyscissor[0] = scissor[0];
8667 }
8668 if (skyscissor[1] > scissor[1])
8669 {
8670 skyscissor[3] += skyscissor[1] - scissor[1];
8671 skyscissor[1] = scissor[1];
8672 }
8673 if (skyscissor[0] + skyscissor[2] < scissor[0] + scissor[2])
8674 skyscissor[2] = scissor[0] + scissor[2] - skyscissor[0];
8675 if (skyscissor[1] + skyscissor[3] < scissor[1] + scissor[3])
8676 skyscissor[3] = scissor[1] + scissor[3] - skyscissor[1];
8677 }
8678 else
8680 }
8681 }
8682
8683 // LadyHavoc: HalfLife maps have freaky skypolys so don't use
8684 // skymasking on them, and Quake3 never did sky masking (unlike
8685 // software Quake and software Quake2), so disable the sky masking
8686 // in Quake3 maps as it causes problems with q3map2 sky tricks,
8687 // and skymasking also looks very bad when noclipping outside the
8688 // level, so don't use it then either.
8690 {
8692 if (skyrendermasked)
8693 {
8694 R_SetupShader_DepthOrShadow(false, false, false);
8695 // depth-only (masking)
8696 GL_ColorMask(0, 0, 0, 0);
8697 // just to make sure that braindead drivers don't draw
8698 // anything despite that colormask...
8702 }
8703 else
8704 {
8705 R_SetupShader_Generic_NoTexture(false, false);
8706 // fog sky
8711 }
8713 if (skyrendermasked)
8715 }
8717 GL_Color(1, 1, 1, 1);
8718}
qbool R_ScissorForBBox(const float *mins, const float *maxs, int *scissor)
Definition gl_backend.c:429
cvar_t r_q3bsp_renderskydepth
Definition gl_rsurf.c:41
#define MATERIALFLAGMASK_DEPTHSORTED
cvar_t r_sky_scissor
Definition r_sky.c:9
int skyrendermasked
Definition r_sky.c:11
int skyrenderlater
Definition r_sky.c:10
int skyscissor[4]
Definition r_sky.c:12

Referenced by R_ProcessModelTextureSurfaceList().

◆ R_EntityMatrix()

void R_EntityMatrix ( const matrix4x4_t matrix)

Definition at line 4425 of file gl_rmain.c.

4426{
4427 if (gl_modelmatrixchanged || memcmp(matrix, &gl_modelmatrix, sizeof(matrix4x4_t)))
4428 {
4429 gl_modelmatrixchanged = false;
4430 gl_modelmatrix = *matrix;
4436 switch(vid.renderpath)
4437 {
4438 case RENDERPATH_GL32:
4439 case RENDERPATH_GLES2:
4442 break;
4443 }
4444 }
4445}
float gl_modelviewprojection16f[16]
Definition gl_backend.c:26
matrix4x4_t gl_modelmatrix
Definition gl_backend.c:20
matrix4x4_t gl_modelviewprojectionmatrix
Definition gl_backend.c:24
matrix4x4_t gl_modelviewmatrix
Definition gl_backend.c:22
matrix4x4_t gl_projectionmatrix
Definition gl_backend.c:23
float gl_modelview16f[16]
Definition gl_backend.c:25
qbool gl_modelmatrixchanged
Definition gl_backend.c:27
matrix4x4_t gl_viewmatrix
Definition gl_backend.c:21
void Matrix4x4_Concat(matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2)
Definition matrixlib.c:83
void Matrix4x4_ToArrayFloatGL(const matrix4x4_t *in, float out[16])
Definition matrixlib.c:1165
int loc_ModelViewProjectionMatrix
Definition gl_rmain.c:812

Referenced by R_BlendView(), R_DrawExplosion_TransparentCallback(), R_DrawLoc_Callback(), R_DrawPortal_Callback(), R_MotionBlurView(), R_ResetViewRendering2D_Common(), R_ResetViewRendering3D(), R_SetViewport(), R_Shadow_DrawCoronas(), R_Shadow_RenderMode_DrawDeferredLight(), RSurf_ActiveCustomEntity(), and RSurf_ActiveModelEntity().

◆ R_EvaluateQ3WaveFunc()

static float R_EvaluateQ3WaveFunc ( q3wavefunc_t  func,
const float parms 
)
static

Definition at line 6443 of file gl_rmain.c.

6444{
6445 double index, f;
6446 index = parms[2] + rsurface.shadertime * parms[3];
6447 index -= floor(index);
6448 switch (func & ((1 << Q3WAVEFUNC_USER_SHIFT) - 1))
6449 {
6450 default:
6451 case Q3WAVEFUNC_NONE:
6452 case Q3WAVEFUNC_NOISE:
6453 case Q3WAVEFUNC_COUNT:
6454 f = 0;
6455 break;
6456 case Q3WAVEFUNC_SIN: f = sin(index * M_PI * 2);break;
6457 case Q3WAVEFUNC_SQUARE: f = index < 0.5 ? 1 : -1;break;
6458 case Q3WAVEFUNC_SAWTOOTH: f = index;break;
6459 case Q3WAVEFUNC_INVERSESAWTOOTH: f = 1 - index;break;
6461 index *= 4;
6462 f = index - floor(index);
6463 if (index < 1)
6464 {
6465 // f = f;
6466 }
6467 else if (index < 2)
6468 f = 1 - f;
6469 else if (index < 3)
6470 f = -f;
6471 else
6472 f = -(1 - f);
6473 break;
6474 }
6475 f = parms[0] + parms[1] * f;
6476 if(func >> Q3WAVEFUNC_USER_SHIFT) // assumes rsurface to be set!
6478 return (float) f;
6479}
#define M_PI
Definition mathlib.h:28
#define Q3WAVEFUNC_USER_COUNT
Definition r_qshader.h:42
#define Q3WAVEFUNC_USER_SHIFT
Definition r_qshader.h:43
@ Q3WAVEFUNC_INVERSESAWTOOTH
Definition r_qshader.h:32
@ Q3WAVEFUNC_SAWTOOTH
Definition r_qshader.h:34
@ Q3WAVEFUNC_TRIANGLE
Definition r_qshader.h:37
@ Q3WAVEFUNC_NOISE
Definition r_qshader.h:33
@ Q3WAVEFUNC_COUNT
Definition r_qshader.h:38
@ Q3WAVEFUNC_NONE
Definition r_qshader.h:31
@ Q3WAVEFUNC_SIN
Definition r_qshader.h:35
@ Q3WAVEFUNC_SQUARE
Definition r_qshader.h:36
float userwavefunc_param[Q3WAVEFUNC_USER_COUNT]
Definition render.h:767
double shadertime
Definition render.h:722

Referenced by R_tcMod_ApplyToMatrix(), and RSurf_PrepareVerticesForBatch().

◆ R_FillColors()

void R_FillColors ( float out,
int  verts,
float  r,
float  g,
float  b,
float  a 
)

Definition at line 335 of file gl_rmain.c.

336{
337 int i;
338 for (i = 0;i < verts;i++)
339 {
340 out[0] = r;
341 out[1] = g;
342 out[2] = b;
343 out[3] = a;
344 out += 4;
345 }
346}

Referenced by R_DrawBBoxMesh().

◆ R_FrameData_Alloc()

void * R_FrameData_Alloc ( size_t  size)

allocate some temporary memory for your purposes

Definition at line 3547 of file gl_rmain.c.

3548{
3549 void *data;
3550 float newvalue;
3551
3552 // align to 16 byte boundary - the data pointer is already aligned, so we
3553 // only need to ensure the size of every allocation is also aligned
3554 size = (size + 15) & ~15;
3555
3557 {
3558 // emergency - we ran out of space, allocate more memory
3559 // note: this has no upper-bound, we'll fail to allocate memory eventually and just die
3561 // upper bound based on architecture - if we try to allocate more than this we could overflow, better to loop until we error out on allocation failure
3562 if (sizeof(size_t) >= 8)
3563 newvalue = bound(0.25f, newvalue, (float)(1ll << 42));
3564 else
3565 newvalue = bound(0.25f, newvalue, (float)(1 << 10));
3566 // this might not be a growing it, but we'll allocate another buffer every time
3568 R_FrameData_Resize(true);
3569 }
3570
3573
3574 // count the usage for stats
3577
3578 return (void *)data;
3579}
static void R_FrameData_Resize(qbool mustgrow)
Definition gl_rmain.c:3511
static r_framedata_mem_t * r_framedata_mem
Definition gl_rmain.c:3499
@ r_stat_framedatacurrent
Definition r_stats.h:51
@ r_stat_framedatasize
Definition r_stats.h:52
unsigned char * data
Definition gl_rmain.c:3495

Referenced by R_AnimCache_GetEntity(), R_FrameData_Store(), R_Q1BSP_CallRecursiveGetLightInfo(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), and RSurf_PrepareVerticesForBatch().

◆ R_FrameData_NewFrame()

void R_FrameData_NewFrame ( void  )

prepare for a new frame, recycles old buffers if a resize occurred previously

Definition at line 3529 of file gl_rmain.c.

3530{
3531 R_FrameData_Resize(false);
3532 if (!r_framedata_mem)
3533 return;
3534 // if we ran out of space on the last frame, free the old memory now
3535 while (r_framedata_mem->purge)
3536 {
3537 // repeatedly remove the second item in the list, leaving only head
3538 r_framedata_mem_t *next = r_framedata_mem->purge->purge;
3540 r_framedata_mem->purge = next;
3541 }
3542 // reset the current mem pointer
3544 r_framedata_mem->mark = 0;
3545}
struct r_framedata_mem_s * purge
Definition gl_rmain.c:3490

Referenced by CL_UpdateScreen().

◆ R_FrameData_Reset()

void R_FrameData_Reset ( void  )

free all R_FrameData memory

Definition at line 3501 of file gl_rmain.c.

3502{
3503 while (r_framedata_mem)
3504 {
3507 r_framedata_mem = next;
3508 }
3509}

Referenced by gl_main_newmap(), gl_main_shutdown(), and gl_main_start().

◆ R_FrameData_Resize()

static void R_FrameData_Resize ( qbool  mustgrow)
static

Definition at line 3511 of file gl_rmain.c.

3512{
3513 size_t wantedsize;
3514 wantedsize = (size_t)(r_framedatasize.value * 1024*1024);
3515 wantedsize = bound(65536, wantedsize, 1000*1024*1024);
3516 if (!r_framedata_mem || r_framedata_mem->wantedsize != wantedsize || mustgrow)
3517 {
3519 newmem->wantedsize = wantedsize;
3520 newmem->data = (unsigned char *)(((size_t)(newmem+1) + 15) & ~15);
3521 newmem->size = (unsigned char *)newmem + wantedsize - newmem->data;
3522 newmem->current = 0;
3523 newmem->mark = 0;
3524 newmem->purge = r_framedata_mem;
3526 }
3527}

Referenced by R_FrameData_Alloc(), and R_FrameData_NewFrame().

◆ R_FrameData_ReturnToMark()

void R_FrameData_ReturnToMark ( void  )

discard recent memory allocations (rewind to marker)

Definition at line 3596 of file gl_rmain.c.

3597{
3598 if (!r_framedata_mem)
3599 return;
3601}

Referenced by R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), and R_RTLight_Compile().

◆ R_FrameData_SetMark()

void R_FrameData_SetMark ( void  )

set a marker that allows you to discard the following temporary memory allocations

Definition at line 3589 of file gl_rmain.c.

3590{
3591 if (!r_framedata_mem)
3592 return;
3594}

Referenced by R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), and R_RTLight_Compile().

◆ R_FrameData_Store()

void * R_FrameData_Store ( size_t  size,
void data 
)

allocate some temporary memory and copy this data into it

Definition at line 3581 of file gl_rmain.c.

3582{
3583 void *d = R_FrameData_Alloc(size);
3584 if (d && data)
3585 memcpy(d, data, size);
3586 return d;
3587}

Referenced by R_Shadow_PrepareLight(), and RSurf_PrepareVerticesForBatch().

◆ R_GetCornerOfBox()

static void R_GetCornerOfBox ( vec3_t  out,
const vec3_t  mins,
const vec3_t  maxs,
int  signbits 
)
static

Definition at line 3446 of file gl_rmain.c.

3447{
3448 out[0] = ((signbits & 1) ? mins : maxs)[0];
3449 out[1] = ((signbits & 2) ? mins : maxs)[1];
3450 out[2] = ((signbits & 4) ? mins : maxs)[2];
3451}

Referenced by _R_CullBox().

◆ R_GetCubemap()

rtexture_t * R_GetCubemap ( const char basename)

Definition at line 2981 of file gl_rmain.c.

2982{
2983 int i;
2984 for (i = 0;i < r_texture_numcubemaps;i++)
2985 if (r_texture_cubemaps[i] != NULL)
2986 if (!strcasecmp(r_texture_cubemaps[i]->basename, basename))
2988 if (i >= MAX_CUBEMAPS || !r_main_mempool)
2989 return r_texture_whitecube;
2992 dp_strlcpy(r_texture_cubemaps[i]->basename, basename, sizeof(r_texture_cubemaps[i]->basename));
2994 return r_texture_cubemaps[i]->texture;
2995}
static rtexture_t * R_LoadCubemap(const char *basename)
Definition gl_rmain.c:2907
#define MAX_CUBEMAPS
max number of cubemap textures loaded for light filters
Definition qdefs.h:130
rtexture_t * texture
Definition gl_rmain.c:290

Referenced by Mod_LoadTextureFromQ3Shader(), R_Shadow_PrepareLight(), and VM_CL_loadcubemap().

◆ R_GetCurrentTexture()

texture_t * R_GetCurrentTexture ( texture_t t)

Definition at line 6585 of file gl_rmain.c.

6586{
6587 int i, q;
6588 const entity_render_t *ent = rsurface.entity;
6589 model_t *model = ent->model; // when calling this, ent must not be NULL
6591 float specularscale = 0.0f;
6592
6594 return t->currentframe;
6596 t->update_lastrenderentity = (void *)ent;
6597
6598 if(ent->entitynumber >= MAX_EDICTS && ent->entitynumber < 2 * MAX_EDICTS)
6599 t->camera_entity = ent->entitynumber;
6600 else
6601 t->camera_entity = 0;
6602
6603 // switch to an alternate material if this is a q1bsp animated material
6604 {
6605 texture_t *texture = t;
6606 int s = rsurface.ent_skinnum;
6607 if ((unsigned int)s >= (unsigned int)model->numskins)
6608 s = 0;
6609 if (model->skinscenes)
6610 {
6611 if (model->skinscenes[s].framecount > 1)
6612 s = model->skinscenes[s].firstframe + (unsigned int) (rsurface.shadertime * model->skinscenes[s].framerate) % model->skinscenes[s].framecount;
6613 else
6614 s = model->skinscenes[s].firstframe;
6615 }
6616 if (s > 0)
6617 t = t + s * model->num_surfaces;
6618 if (t->animated)
6619 {
6620 // use an alternate animation if the entity's frame is not 0,
6621 // and only if the texture has an alternate animation
6622 if (t->animated == 2) // q2bsp
6623 t = t->anim_frames[0][ent->framegroupblend[0].frame % t->anim_total[0]];
6624 else if (rsurface.ent_alttextures && t->anim_total[1])
6625 t = t->anim_frames[1][(t->anim_total[1] >= 2) ? ((int)(rsurface.shadertime * 5.0f) % t->anim_total[1]) : 0];
6626 else
6627 t = t->anim_frames[0][(t->anim_total[0] >= 2) ? ((int)(rsurface.shadertime * 5.0f) % t->anim_total[0]) : 0];
6628 }
6629 texture->currentframe = t;
6630 }
6631
6632 // update currentskinframe to be a qw skin or animation frame
6633 if (rsurface.ent_qwskin >= 0)
6634 {
6637 {
6639 if (r_qwskincache)
6642 }
6648 }
6649 else if (t->materialshaderpass && t->materialshaderpass->numframes >= 2)
6653
6662
6663 // decide on which type of lighting to use for this surface
6671 {
6672 // some CUSTOMBLEND blendfuncs are too weird, we have to ignore colormod and view colorscale
6674 for (q = 0; q < 3; q++)
6675 {
6682 t->render_lightmap_ambient[q] = 0;
6683 t->render_lightmap_diffuse[q] = 0;
6685 t->render_rtlight_diffuse[q] = 0;
6686 t->render_rtlight_specular[q] = 0;
6687 }
6688 }
6690 {
6691 // fullbright is basically MATERIALFLAG_MODELLIGHT but with ambient locked to 1,1,1 and no shading
6693 for (q = 0; q < 3; q++)
6694 {
6701 t->render_lightmap_ambient[q] = 0;
6702 t->render_lightmap_diffuse[q] = 0;
6704 t->render_rtlight_diffuse[q] = 0;
6705 t->render_rtlight_specular[q] = 0;
6706 }
6707 }
6709 {
6711 for (q = 0; q < 3; q++)
6712 {
6724 }
6725 }
6727 {
6728 // ambient + single direction light (modellight)
6730 for (q = 0; q < 3; q++)
6731 {
6738 t->render_lightmap_ambient[q] = 0;
6739 t->render_lightmap_diffuse[q] = 0;
6743 }
6744 }
6745 else
6746 {
6747 // lightmap - 2x diffuse and specular brightness because bsp files have 0-2 colors as 0-1
6748 for (q = 0; q < 3; q++)
6749 {
6761 }
6762 }
6763
6765 {
6766 // since MATERIALFLAG_VERTEXCOLOR uses the lightmapcolor4f vertex
6767 // attribute, we punt it to the lightmap path and hope for the best,
6768 // but lighting doesn't work.
6769 //
6770 // FIXME: this is fine for effects but CSQC polygons should be subject
6771 // to lighting.
6773 for (q = 0; q < 3; q++)
6774 {
6781 t->render_lightmap_ambient[q] = 0;
6784 t->render_rtlight_diffuse[q] = 0;
6785 t->render_rtlight_specular[q] = 0;
6786 }
6787 }
6788
6789 for (q = 0; q < 3; q++)
6790 {
6793 }
6794
6797 else if (t->currentalpha < 1)
6799 // LadyHavoc: prevent bugs where code checks add or alpha at higher priority than customblend by clearing these flags
6806 if (t->backgroundshaderpass)
6809 {
6812 }
6813 else
6816 {
6817 // promote alphablend to alphatocoverage (a type of alphatest) if antialiasing is on
6819 }
6822
6823 // there is no tcmod
6825 {
6828 }
6830 {
6833 }
6834
6835 if (t->materialshaderpass)
6836 for (i = 0, tcmod = t->materialshaderpass->tcmods;i < Q3MAXTCMODS && tcmod->tcmod;i++, tcmod++)
6838
6840 if (t->currentskinframe->qpixels)
6842 t->basetexture = (!t->colormapping && t->currentskinframe->merged) ? t->currentskinframe->merged : t->currentskinframe->base;
6843 if (!t->basetexture)
6845 t->pantstexture = t->colormapping ? t->currentskinframe->pants : NULL;
6846 t->shirttexture = t->colormapping ? t->currentskinframe->shirt : NULL;
6847 t->nmaptexture = t->currentskinframe->nmap;
6848 if (!t->nmaptexture)
6851 t->glowtexture = t->currentskinframe->glow;
6852 t->fogtexture = t->currentskinframe->fog;
6853 t->reflectmasktexture = t->currentskinframe->reflect;
6854 if (t->backgroundshaderpass)
6855 {
6856 for (i = 0, tcmod = t->backgroundshaderpass->tcmods; i < Q3MAXTCMODS && tcmod->tcmod; i++, tcmod++)
6858 t->backgroundbasetexture = (!t->colormapping && t->backgroundcurrentskinframe->merged) ? t->backgroundcurrentskinframe->merged : t->backgroundcurrentskinframe->base;
6862 if (!t->backgroundnmaptexture)
6864 // make sure that if glow is going to be used, both textures are not NULL
6865 if (!t->backgroundglowtexture && t->glowtexture)
6867 if (!t->glowtexture && t->backgroundglowtexture)
6869 }
6870 else
6871 {
6876 }
6878 // TODO: store reference values for these in the texture?
6879 if (r_shadow_gloss.integer > 0)
6880 {
6882 {
6884 {
6887 specularscale = r_shadow_glossintensity.value;
6888 }
6889 }
6891 {
6894 specularscale = r_shadow_gloss2intensity.value;
6896 }
6897 }
6898 specularscale *= t->specularscalemod;
6900
6901 // lightmaps mode looks bad with dlights using actual texturing, so turn
6902 // off the colormap and glossmap, but leave the normalmap on as it still
6903 // accurately represents the shading involved
6905 {
6909 if (gl_lightmaps.integer < 2)
6912 t->glowtexture = NULL;
6913 t->fogtexture = NULL;
6916 if (gl_lightmaps.integer < 2)
6920 specularscale = 0;
6922 }
6923
6924 if (specularscale != 1.0f)
6925 {
6926 for (q = 0; q < 3; q++)
6927 {
6928 t->render_modellight_specular[q] *= specularscale;
6929 t->render_lightmap_specular[q] *= specularscale;
6930 t->render_rtlight_specular[q] *= specularscale;
6931 }
6932 }
6933
6934 t->currentblendfunc[0] = GL_ONE;
6935 t->currentblendfunc[1] = GL_ZERO;
6937 {
6939 t->currentblendfunc[1] = GL_ONE;
6940 }
6942 {
6945 }
6947 {
6948 t->currentblendfunc[0] = t->customblendfunc[0];
6949 t->currentblendfunc[1] = t->customblendfunc[1];
6950 }
6951
6952 return t;
6953}
entity_t cl_meshentities[NUM_MESHENTITIES]
Definition cl_main.c:2515
@ MESH_UI
Definition client.h:1365
static void R_LoadQWSkin(r_qwskincache_t *cache, const char *skinname)
Definition gl_rmain.c:6558
static void R_SkinFrame_GenerateTexturesFromQPixels(skinframe_t *skinframe, qbool colormapped)
Definition gl_rmain.c:2675
int r_textureframe
used only by R_GetCurrentTexture, incremented per view and per UI render
Definition gl_rmain.c:45
matrix4x4_t r_waterscrollmatrix
Definition gl_rmain.c:5402
static void R_tcMod_ApplyToMatrix(matrix4x4_t *texmatrix, q3shaderinfo_layer_tcmod_t *tcmod, int currentmaterialflags)
Definition gl_rmain.c:6481
static int R_BlendFuncFlags(int src, int dst)
Definition gl_rmain.c:1521
const GLchar * name
Definition glquake.h:600
int LoopingFrameNumberFromDouble(double t, int loopframes)
Definition mathlib.c:891
#define VectorLength2(a)
Definition mathlib.h:109
void Matrix4x4_CreateIdentity(matrix4x4_t *out)
Definition matrixlib.c:564
cvar_t r_shadow_gloss
Definition r_shadow.c:147
cvar_t r_novis
Definition model_brush.c:31
#define MATERIALFLAG_ADD
Definition model_brush.h:81
#define MATERIALFLAG_FULLBRIGHT
Definition model_brush.h:87
#define MATERIALFLAG_VERTEXTEXTUREBLEND
#define MATERIALFLAG_LIGHTGRID
#define MATERIALFLAG_MODELLIGHT
#define MATERIALFLAG_WATERSCROLL
Definition model_brush.h:94
#define MATERIALFLAG_CUSTOMBLEND
#define MATERIALFLAG_NORTLIGHT
#define RENDER_DYNAMICMODELLIGHT
Definition protocol.h:374
#define RENDER_LIGHT
Definition protocol.h:367
#define RENDER_CUSTOMIZEDMODELLIGHT
Definition protocol.h:373
#define MAX_EDICTS
max number of objects in game world at once (32768 protocol limit)
Definition qdefs.h:105
#define Q3MAXTCMODS
Definition r_qshader.h:26
cvar_t r_shadow_glossintensity
Definition r_shadow.c:149
cvar_t r_shadow_gloss2intensity
Definition r_shadow.c:148
cvar_t r_shadow_glossexponent
Definition r_shadow.c:150
cvar_t r_shadow_gloss2exponent
Definition r_shadow.c:151
float framerate
scoreboard_t * scores
Definition client.h:946
float render_rtlight_diffuse[3]
Definition client.h:427
float render_glowmod[3]
Definition client.h:415
float render_modellight_specular[3]
Definition client.h:421
qbool render_rtlight_disabled
Definition client.h:432
float render_modellight_lightdir_world[3]
Definition client.h:419
float render_lightmap_ambient[3]
Definition client.h:423
float render_modellight_lightdir_local[3]
Definition client.h:420
vec3_t colormap_shirtcolor
Definition client.h:349
qbool render_modellight_forced
Definition client.h:430
framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS]
Definition client.h:364
float render_lightmap_diffuse[3]
Definition client.h:424
float render_modellight_ambient[3]
Definition client.h:417
float render_rtlight_specular[3]
Definition client.h:428
float render_lightmap_specular[3]
Definition client.h:425
qbool render_lightgrid
Definition client.h:434
float render_modellight_diffuse[3]
Definition client.h:418
float glowmod[3]
Definition client.h:361
vec3_t colormap_pantscolor
Definition client.h:348
entity_render_t render
Definition client.h:478
qbool supportwateralpha
animscene_t * skinscenes
skinframe_t * skinframe
Definition gl_rmain.c:304
qbool isoverlay
if true, don't clear or do any post process effects (bloom, etc)
Definition render.h:307
qbool enabled
Definition render.h:879
int ent_alttextures
Definition render.h:721
float * modeltexcoordlightmap2f
Definition render.h:645
qbool forcecurrenttextureupdate
Definition render.h:615
char qw_skin[MAX_QPATH]
Definition client.h:502
q3shaderinfo_layer_tcmod_t tcmods[Q3MAXTCMODS]
Definition r_qshader.h:270
struct skinframe_s * skinframes[TEXTURE_MAXFRAMES]
Definition r_qshader.h:265
float specularpower
struct skinframe_s * backgroundcurrentskinframe
struct rtexture_s * basetexture
int currentblendfunc[2]
float render_rtlight_specular[3]
matrix4x4_t currenttexmatrix
qbool colormapping
struct rtexture_s * glosstexture
float render_modellight_lightdir_world[3]
float render_glowmod[3]
struct rtexture_s * nmaptexture
int anim_total[2]
struct rtexture_s * backgroundglosstexture
struct rtexture_s * backgroundbasetexture
texture_shaderpass_t * backgroundshaderpass
int camera_entity
void * update_lastrenderentity
float basealpha
float render_modellight_diffuse[3]
float render_rtlight_diffuse[3]
float render_modellight_ambient[3]
float specularpowermod
int basematerialflags
struct texture_s * currentframe
struct rtexture_s * glowtexture
float render_modellight_lightdir_local[3]
struct rtexture_s * backgroundglowtexture
float render_lightmap_specular[3]
struct rtexture_s * reflectmasktexture
matrix4x4_t currentbackgroundtexmatrix
struct rtexture_s * fogtexture
float render_lightmap_diffuse[3]
texture_shaderpass_t * materialshaderpass
float render_lightmap_ambient[3]
float specularscalemod
struct rtexture_s * backgroundnmaptexture
float render_modellight_specular[3]
struct texture_s * anim_frames[2][10]
int customblendfunc[2]
qbool allowalphatocoverage
Definition vid.h:88

Referenced by R_DrawCustomSurface_Texture(), R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Model_Sprite_Draw_TransparentCallback(), R_Q1BSP_DrawLight_TransparentCallback(), R_Q1BSP_RecursiveGetLightInfo_BIH(), R_Q1BSP_RecursiveGetLightInfo_BSP(), R_QueueModelSurfaceList(), and R_Water_AddWaterPlane().

◆ R_GetScenePointer()

r_refdef_scene_t * R_GetScenePointer ( r_refdef_scene_type_t  scenetype)

Definition at line 5596 of file gl_rmain.c.

5597{
5598 // of course, we could also add a qbool that provides a lock state and a ReleaseScenePointer function..
5599 if( scenetype == r_currentscenetype ) {
5600 return &r_refdef.scene;
5601 } else {
5602 return &r_scenes_store[ scenetype ];
5603 }
5604}
static r_refdef_scene_type_t r_currentscenetype
Definition gl_rmain.c:5574
static r_refdef_scene_t r_scenes_store[RST_COUNT]
Definition gl_rmain.c:5575

Referenced by MVM_init_cmd().

◆ R_GLSL_CompilePermutation()

static void R_GLSL_CompilePermutation ( r_glsl_permutation_t p,
unsigned int  mode,
uint64_t  permutation 
)
static

Definition at line 1024 of file gl_rmain.c.

1025{
1026 unsigned i;
1027 int ubibind;
1028 int sampler;
1030 char *sourcestring;
1031 char permutationname[256];
1032 int vertstrings_count = 0;
1033 int geomstrings_count = 0;
1034 int fragstrings_count = 0;
1035 const char *vertstrings_list[32+5+SHADERSTATICPARMS_COUNT+1];
1036 const char *geomstrings_list[32+5+SHADERSTATICPARMS_COUNT+1];
1037 const char *fragstrings_list[32+5+SHADERSTATICPARMS_COUNT+1];
1038
1039 if (p->compiled)
1040 return;
1041 p->compiled = true;
1042 p->program = 0;
1043
1044 permutationname[0] = 0;
1046
1048
1049 // we need 140 for r_glsl_skeletal (GL_ARB_uniform_buffer_object)
1050 if(vid.support.glshaderversion >= 140)
1051 {
1052 vertstrings_list[vertstrings_count++] = "#version 140\n";
1053 geomstrings_list[geomstrings_count++] = "#version 140\n";
1054 fragstrings_list[fragstrings_count++] = "#version 140\n";
1055 vertstrings_list[vertstrings_count++] = "#define GLSL140\n";
1056 geomstrings_list[geomstrings_count++] = "#define GLSL140\n";
1057 fragstrings_list[fragstrings_count++] = "#define GLSL140\n";
1058 }
1059 // if we can do #version 130, we should (this improves quality of offset/reliefmapping thanks to textureGrad)
1060 else if(vid.support.glshaderversion >= 130)
1061 {
1062 vertstrings_list[vertstrings_count++] = "#version 130\n";
1063 geomstrings_list[geomstrings_count++] = "#version 130\n";
1064 fragstrings_list[fragstrings_count++] = "#version 130\n";
1065 vertstrings_list[vertstrings_count++] = "#define GLSL130\n";
1066 geomstrings_list[geomstrings_count++] = "#define GLSL130\n";
1067 fragstrings_list[fragstrings_count++] = "#define GLSL130\n";
1068 }
1069 // if we can do #version 120, we should (this adds the invariant keyword)
1070 else if(vid.support.glshaderversion >= 120)
1071 {
1072 vertstrings_list[vertstrings_count++] = "#version 120\n";
1073 geomstrings_list[geomstrings_count++] = "#version 120\n";
1074 fragstrings_list[fragstrings_count++] = "#version 120\n";
1075 vertstrings_list[vertstrings_count++] = "#define GLSL120\n";
1076 geomstrings_list[geomstrings_count++] = "#define GLSL120\n";
1077 fragstrings_list[fragstrings_count++] = "#define GLSL120\n";
1078 }
1079 // GLES also adds several things from GLSL120
1080 switch(vid.renderpath)
1081 {
1082 case RENDERPATH_GLES2:
1083 vertstrings_list[vertstrings_count++] = "#define GLES\n";
1084 geomstrings_list[geomstrings_count++] = "#define GLES\n";
1085 fragstrings_list[fragstrings_count++] = "#define GLES\n";
1086 break;
1087 default:
1088 break;
1089 }
1090
1091 // the first pretext is which type of shader to compile as
1092 // (later these will all be bound together as a program object)
1093 vertstrings_list[vertstrings_count++] = "#define VERTEX_SHADER\n";
1094 geomstrings_list[geomstrings_count++] = "#define GEOMETRY_SHADER\n";
1095 fragstrings_list[fragstrings_count++] = "#define FRAGMENT_SHADER\n";
1096
1097 // the second pretext is the mode (for example a light source)
1102
1103 // now add all the permutation pretexts
1104 for (i = 0;i < SHADERPERMUTATION_COUNT;i++)
1105 {
1106 if (permutation & (1ll<<i))
1107 {
1112 }
1113 else
1114 {
1115 // keep line numbers correct
1119 }
1120 }
1121
1122 // add static parms
1130
1131 // now append the shader text itself
1135
1136 // we don't currently use geometry shaders for anything, so just empty the list
1138
1139 // compile the shader program
1142 if (p->program)
1143 {
1146 // look up all the uniform variable names we care about, so we don't
1147 // have to look them up every time we set them
1148
1149#if 0
1150 // debugging aid
1151 {
1154 char uniformname[128];
1156 GLint uniformsize = 0;
1157 GLenum uniformtype = 0;
1158 memset(uniformname, 0, sizeof(uniformname));
1160 Con_Printf("Shader has %i uniforms\n", numactiveuniforms);
1162 {
1164 Con_Printf("Uniform %i name \"%s\" size %i type %i\n", (int)activeuniformindex, uniformname, (int)uniformsize, (int)uniformtype);
1165 }
1166 }
1167#endif
1168
1169 p->loc_Texture_First = qglGetUniformLocation(p->program, "Texture_First");
1170 p->loc_Texture_Second = qglGetUniformLocation(p->program, "Texture_Second");
1171 p->loc_Texture_GammaRamps = qglGetUniformLocation(p->program, "Texture_GammaRamps");
1172 p->loc_Texture_Normal = qglGetUniformLocation(p->program, "Texture_Normal");
1173 p->loc_Texture_Color = qglGetUniformLocation(p->program, "Texture_Color");
1174 p->loc_Texture_Gloss = qglGetUniformLocation(p->program, "Texture_Gloss");
1175 p->loc_Texture_Glow = qglGetUniformLocation(p->program, "Texture_Glow");
1176 p->loc_Texture_SecondaryNormal = qglGetUniformLocation(p->program, "Texture_SecondaryNormal");
1177 p->loc_Texture_SecondaryColor = qglGetUniformLocation(p->program, "Texture_SecondaryColor");
1178 p->loc_Texture_SecondaryGloss = qglGetUniformLocation(p->program, "Texture_SecondaryGloss");
1179 p->loc_Texture_SecondaryGlow = qglGetUniformLocation(p->program, "Texture_SecondaryGlow");
1180 p->loc_Texture_Pants = qglGetUniformLocation(p->program, "Texture_Pants");
1181 p->loc_Texture_Shirt = qglGetUniformLocation(p->program, "Texture_Shirt");
1182 p->loc_Texture_FogHeightTexture = qglGetUniformLocation(p->program, "Texture_FogHeightTexture");
1183 p->loc_Texture_FogMask = qglGetUniformLocation(p->program, "Texture_FogMask");
1184 p->loc_Texture_LightGrid = qglGetUniformLocation(p->program, "Texture_LightGrid");
1185 p->loc_Texture_Lightmap = qglGetUniformLocation(p->program, "Texture_Lightmap");
1186 p->loc_Texture_Deluxemap = qglGetUniformLocation(p->program, "Texture_Deluxemap");
1187 p->loc_Texture_Attenuation = qglGetUniformLocation(p->program, "Texture_Attenuation");
1188 p->loc_Texture_Cube = qglGetUniformLocation(p->program, "Texture_Cube");
1189 p->loc_Texture_Refraction = qglGetUniformLocation(p->program, "Texture_Refraction");
1190 p->loc_Texture_Reflection = qglGetUniformLocation(p->program, "Texture_Reflection");
1191 p->loc_Texture_ShadowMap2D = qglGetUniformLocation(p->program, "Texture_ShadowMap2D");
1192 p->loc_Texture_CubeProjection = qglGetUniformLocation(p->program, "Texture_CubeProjection");
1193 p->loc_Texture_ScreenNormalMap = qglGetUniformLocation(p->program, "Texture_ScreenNormalMap");
1194 p->loc_Texture_ScreenDiffuse = qglGetUniformLocation(p->program, "Texture_ScreenDiffuse");
1195 p->loc_Texture_ScreenSpecular = qglGetUniformLocation(p->program, "Texture_ScreenSpecular");
1196 p->loc_Texture_ReflectMask = qglGetUniformLocation(p->program, "Texture_ReflectMask");
1197 p->loc_Texture_ReflectCube = qglGetUniformLocation(p->program, "Texture_ReflectCube");
1198 p->loc_Texture_BounceGrid = qglGetUniformLocation(p->program, "Texture_BounceGrid");
1199 p->loc_Alpha = qglGetUniformLocation(p->program, "Alpha");
1200 p->loc_BloomBlur_Parameters = qglGetUniformLocation(p->program, "BloomBlur_Parameters");
1201 p->loc_ClientTime = qglGetUniformLocation(p->program, "ClientTime");
1202 p->loc_Color_Ambient = qglGetUniformLocation(p->program, "Color_Ambient");
1203 p->loc_Color_Diffuse = qglGetUniformLocation(p->program, "Color_Diffuse");
1204 p->loc_Color_Specular = qglGetUniformLocation(p->program, "Color_Specular");
1205 p->loc_Color_Glow = qglGetUniformLocation(p->program, "Color_Glow");
1206 p->loc_Color_Pants = qglGetUniformLocation(p->program, "Color_Pants");
1207 p->loc_Color_Shirt = qglGetUniformLocation(p->program, "Color_Shirt");
1208 p->loc_DeferredColor_Ambient = qglGetUniformLocation(p->program, "DeferredColor_Ambient");
1209 p->loc_DeferredColor_Diffuse = qglGetUniformLocation(p->program, "DeferredColor_Diffuse");
1210 p->loc_DeferredColor_Specular = qglGetUniformLocation(p->program, "DeferredColor_Specular");
1211 p->loc_DeferredMod_Diffuse = qglGetUniformLocation(p->program, "DeferredMod_Diffuse");
1212 p->loc_DeferredMod_Specular = qglGetUniformLocation(p->program, "DeferredMod_Specular");
1213 p->loc_DistortScaleRefractReflect = qglGetUniformLocation(p->program, "DistortScaleRefractReflect");
1214 p->loc_EyePosition = qglGetUniformLocation(p->program, "EyePosition");
1215 p->loc_FogColor = qglGetUniformLocation(p->program, "FogColor");
1216 p->loc_FogHeightFade = qglGetUniformLocation(p->program, "FogHeightFade");
1217 p->loc_FogPlane = qglGetUniformLocation(p->program, "FogPlane");
1218 p->loc_FogPlaneViewDist = qglGetUniformLocation(p->program, "FogPlaneViewDist");
1219 p->loc_FogRangeRecip = qglGetUniformLocation(p->program, "FogRangeRecip");
1220 p->loc_LightColor = qglGetUniformLocation(p->program, "LightColor");
1221 p->loc_LightGridMatrix = qglGetUniformLocation(p->program, "LightGridMatrix");
1222 p->loc_LightGridNormalMatrix = qglGetUniformLocation(p->program, "LightGridNormalMatrix");
1223 p->loc_LightDir = qglGetUniformLocation(p->program, "LightDir");
1224 p->loc_LightPosition = qglGetUniformLocation(p->program, "LightPosition");
1225 p->loc_OffsetMapping_ScaleSteps = qglGetUniformLocation(p->program, "OffsetMapping_ScaleSteps");
1226 p->loc_OffsetMapping_LodDistance = qglGetUniformLocation(p->program, "OffsetMapping_LodDistance");
1227 p->loc_OffsetMapping_Bias = qglGetUniformLocation(p->program, "OffsetMapping_Bias");
1228 p->loc_PixelSize = qglGetUniformLocation(p->program, "PixelSize");
1229 p->loc_ReflectColor = qglGetUniformLocation(p->program, "ReflectColor");
1230 p->loc_ReflectFactor = qglGetUniformLocation(p->program, "ReflectFactor");
1231 p->loc_ReflectOffset = qglGetUniformLocation(p->program, "ReflectOffset");
1232 p->loc_RefractColor = qglGetUniformLocation(p->program, "RefractColor");
1233 p->loc_Saturation = qglGetUniformLocation(p->program, "Saturation");
1234 p->loc_ScreenCenterRefractReflect = qglGetUniformLocation(p->program, "ScreenCenterRefractReflect");
1235 p->loc_ScreenScaleRefractReflect = qglGetUniformLocation(p->program, "ScreenScaleRefractReflect");
1236 p->loc_ScreenToDepth = qglGetUniformLocation(p->program, "ScreenToDepth");
1237 p->loc_ShadowMap_Parameters = qglGetUniformLocation(p->program, "ShadowMap_Parameters");
1238 p->loc_ShadowMap_TextureScale = qglGetUniformLocation(p->program, "ShadowMap_TextureScale");
1239 p->loc_SpecularPower = qglGetUniformLocation(p->program, "SpecularPower");
1240 p->loc_UserVec1 = qglGetUniformLocation(p->program, "UserVec1");
1241 p->loc_UserVec2 = qglGetUniformLocation(p->program, "UserVec2");
1242 p->loc_UserVec3 = qglGetUniformLocation(p->program, "UserVec3");
1243 p->loc_UserVec4 = qglGetUniformLocation(p->program, "UserVec4");
1244 p->loc_ColorFringe = qglGetUniformLocation(p->program, "ColorFringe");
1245 p->loc_ViewTintColor = qglGetUniformLocation(p->program, "ViewTintColor");
1246 p->loc_ViewToLight = qglGetUniformLocation(p->program, "ViewToLight");
1247 p->loc_ModelToLight = qglGetUniformLocation(p->program, "ModelToLight");
1248 p->loc_TexMatrix = qglGetUniformLocation(p->program, "TexMatrix");
1249 p->loc_BackgroundTexMatrix = qglGetUniformLocation(p->program, "BackgroundTexMatrix");
1250 p->loc_ModelViewMatrix = qglGetUniformLocation(p->program, "ModelViewMatrix");
1251 p->loc_ModelViewProjectionMatrix = qglGetUniformLocation(p->program, "ModelViewProjectionMatrix");
1252 p->loc_PixelToScreenTexCoord = qglGetUniformLocation(p->program, "PixelToScreenTexCoord");
1253 p->loc_ModelToReflectCube = qglGetUniformLocation(p->program, "ModelToReflectCube");
1254 p->loc_ShadowMapMatrix = qglGetUniformLocation(p->program, "ShadowMapMatrix");
1255 p->loc_BloomColorSubtract = qglGetUniformLocation(p->program, "BloomColorSubtract");
1256 p->loc_NormalmapScrollBlend = qglGetUniformLocation(p->program, "NormalmapScrollBlend");
1257 p->loc_BounceGridMatrix = qglGetUniformLocation(p->program, "BounceGridMatrix");
1258 p->loc_BounceGridIntensity = qglGetUniformLocation(p->program, "BounceGridIntensity");
1259 // initialize the samplers to refer to the texture units we use
1260 p->tex_Texture_First = -1;
1261 p->tex_Texture_Second = -1;
1262 p->tex_Texture_GammaRamps = -1;
1263 p->tex_Texture_Normal = -1;
1264 p->tex_Texture_Color = -1;
1265 p->tex_Texture_Gloss = -1;
1266 p->tex_Texture_Glow = -1;
1271 p->tex_Texture_Pants = -1;
1272 p->tex_Texture_Shirt = -1;
1274 p->tex_Texture_FogMask = -1;
1275 p->tex_Texture_LightGrid = -1;
1276 p->tex_Texture_Lightmap = -1;
1277 p->tex_Texture_Deluxemap = -1;
1279 p->tex_Texture_Cube = -1;
1280 p->tex_Texture_Refraction = -1;
1281 p->tex_Texture_Reflection = -1;
1289 p->tex_Texture_BounceGrid = -1;
1290 // bind the texture samplers in use
1291 sampler = 0;
1322 // get the uniform block indices so we can bind them
1324#ifndef USE_GLES2 /* FIXME: GLES3 only */
1325 p->ubiloc_Skeletal_Transform12_UniformBlock = qglGetUniformBlockIndex(p->program, "Skeletal_Transform12_UniformBlock");
1326#endif
1327 // clear the uniform block bindings
1329 // bind the uniform blocks in use
1330 ubibind = 0;
1331#ifndef USE_GLES2 /* FIXME: GLES3 only */
1333#endif
1334 // we're done compiling and setting up the shader, at least until it is used
1336 Con_DPrintf("^5GLSL shader %s compiled (%i textures).\n", permutationname, sampler);
1337 }
1338 else
1339 Con_Printf("^1GLSL shader %s failed! some features may not work properly.\n", permutationname);
1340
1341 // free the strings
1342 if (sourcestring)
1344}
#define dp_strlcat(dst, src, dsize)
Definition common.h:299
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1460
unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int geometrystrings_count, const char **geometrystrings_list, int fragmentstrings_count, const char **fragmentstrings_list)
shadermodeinfo_t shadermodeinfo[SHADERLANGUAGE_COUNT][SHADERMODE_COUNT]
Definition gl_rmain.c:662
static char * ShaderModeInfo_GetShaderText(shadermodeinfo_t *modeinfo, qbool printfromdisknotice, qbool builtinonly)
Definition gl_rmain.c:1006
shaderpermutationinfo_t shaderpermutationinfo[SHADERPERMUTATION_COUNT]
Definition gl_rmain.c:625
static void R_CompileShader_AddStaticParms(unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:911
int GLint
Definition glquake.h:51
GLenum mode
Definition glquake.h:717
unsigned int GLenum
Definition glquake.h:45
int GLsizei
Definition glquake.h:55
#define GL_ACTIVE_UNIFORMS
Definition glquake.h:453
#define SHADERPERMUTATION_COUNT
size of shaderpermutationinfo array
Definition render.h:105
@ SHADERLANGUAGE_GLSL
Definition render.h:44
int loc_Texture_FogHeightTexture
Definition gl_rmain.c:743
int tex_Texture_SecondaryNormal
Definition gl_rmain.c:706
int loc_Texture_First
locations of detected uniforms in program object, or -1 if not found
Definition gl_rmain.c:730
int tex_Texture_FogHeightTexture
Definition gl_rmain.c:712
int loc_ScreenCenterRefractReflect
Definition gl_rmain.c:795
int loc_Texture_SecondaryNormal
Definition gl_rmain.c:737
int loc_Texture_ScreenNormalMap
Definition gl_rmain.c:754
int program
0 if compilation failed
Definition gl_rmain.c:697
int ubibind_Skeletal_Transform12_UniformBlock
uniform block bindings
Definition gl_rmain.c:822
qbool compiled
indicates if we have tried compiling this permutation already
Definition gl_rmain.c:695
int ubiloc_Skeletal_Transform12_UniformBlock
uniform block indices
Definition gl_rmain.c:824
int loc_ScreenScaleRefractReflect
Definition gl_rmain.c:796
int loc_OffsetMapping_ScaleSteps
Definition gl_rmain.c:786
int loc_DistortScaleRefractReflect
Definition gl_rmain.c:774
int loc_OffsetMapping_LodDistance
Definition gl_rmain.c:787
int tex_Texture_ScreenNormalMap
Definition gl_rmain.c:723
const char * pretext
Definition gl_rmain.c:606
int glshaderversion
Definition vid.h:45

Referenced by R_SetupShader_SetPermutationGLSL().

◆ R_GLSL_DumpShader_f()

static void R_GLSL_DumpShader_f ( cmd_state_t cmd)
static

Definition at line 1419 of file gl_rmain.c.

1420{
1421 unsigned i, language, mode, dupe;
1422 char *text;
1424 qfile_t *file;
1425
1427 {
1429 for (mode = 0;mode < SHADERMODE_COUNT;mode++)
1430 {
1431 // don't dump the same file multiple times (most or all shaders come from the same file)
1432 for (dupe = mode - 1;dupe >= 0;dupe--)
1433 if (!strcmp(modeinfo[mode].filename, modeinfo[dupe].filename))
1434 break;
1435 if (dupe >= 0)
1436 continue;
1437 text = modeinfo[mode].builtinstring;
1438 if (!text)
1439 continue;
1440 file = FS_OpenRealFile(modeinfo[mode].filename, "w", false);
1441 if (file)
1442 {
1443 FS_Print(file, "/* The engine may define the following macros:\n");
1444 FS_Print(file, "#define VERTEX_SHADER\n#define GEOMETRY_SHADER\n#define FRAGMENT_SHADER\n");
1445 for (i = 0;i < SHADERMODE_COUNT;i++)
1446 FS_Print(file, modeinfo[i].pretext);
1447 for (i = 0;i < SHADERPERMUTATION_COUNT;i++)
1448 FS_Print(file, shaderpermutationinfo[i].pretext);
1449 FS_Print(file, "*/\n");
1450 FS_Print(file, text);
1451 FS_Close(file);
1452 Con_Printf("%s written\n", modeinfo[mode].filename);
1453 }
1454 else
1455 Con_Printf(CON_ERROR "failed to write to %s\n", modeinfo[mode].filename);
1456 }
1457 }
1458}
#define CON_ERROR
Definition console.h:97
qfile_t * FS_OpenRealFile(const char *filepath, const char *mode, qbool quiet)
Definition fs.c:2886
int FS_Close(qfile_t *file)
Definition fs.c:2955
int FS_Print(qfile_t *file, const char *msg)
Definition fs.c:3246
@ SHADERMODE_COUNT
Definition render.h:69
@ SHADERLANGUAGE_COUNT
Definition render.h:45
char * builtinstring
Definition gl_rmain.c:619

Referenced by GL_Main_Init().

◆ R_GLSL_FindPermutation()

static r_glsl_permutation_t * R_GLSL_FindPermutation ( unsigned int  mode,
uint64_t  permutation 
)
static

Definition at line 940 of file gl_rmain.c.

941{
942 //unsigned int hashdepth = 0;
943 unsigned int hashindex = (permutation * 0x1021) & (SHADERPERMUTATION_HASHSIZE - 1);
945 for (p = r_glsl_permutationhash[mode][hashindex];p;p = p->hashnext)
946 {
947 if (p->mode == mode && p->permutation == permutation)
948 {
949 //if (hashdepth > 10)
950 // Con_Printf("R_GLSL_FindPermutation: Warning: %i:%i has hashdepth %i\n", mode, permutation, hashdepth);
951 return p;
952 }
953 //hashdepth++;
954 }
956 p->mode = mode;
957 p->permutation = permutation;
960 //if (hashdepth > 10)
961 // Con_Printf("R_GLSL_FindPermutation: Warning: %i:%i has hashdepth %i\n", mode, permutation, hashdepth);
962 return p;
963}
#define SHADERPERMUTATION_HASHSIZE
Definition gl_rmain.c:828
struct r_glsl_permutation_s * hashnext
hash lookup data
Definition gl_rmain.c:690
unsigned int mode
Definition gl_rmain.c:691
void * Mem_ExpandableArray_AllocRecord(memexpandablearray_t *l)
Definition zone.c:695

Referenced by R_SetupShader_SetPermutationGLSL().

◆ R_GLSL_Restart_f()

void R_GLSL_Restart_f ( cmd_state_t cmd)

Definition at line 1394 of file gl_rmain.c.

1395{
1396 unsigned int i, limit;
1397 switch(vid.renderpath)
1398 {
1399 case RENDERPATH_GL32:
1400 case RENDERPATH_GLES2:
1401 {
1405 for (i = 0;i < limit;i++)
1406 {
1408 {
1411 }
1412 }
1414 }
1415 break;
1416 }
1417}
void GL_Backend_FreeProgram(unsigned int prog)
size_t Mem_ExpandableArray_IndexRange(const memexpandablearray_t *l)
Definition zone.c:763
void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record)
Definition zone.c:743

Referenced by GL_Main_Init(), gl_main_shutdown(), R_RenderView(), and R_Shadow_SetShadowMode().

◆ R_HDR_UpdateIrisAdaptation()

void R_HDR_UpdateIrisAdaptation ( const vec3_t  point)

Definition at line 4152 of file gl_rmain.c.

4153{
4155 {
4156 vec3_t p;
4161 vec_t brightness = 0.0f;
4162 vec_t goal;
4163 vec_t current;
4164 vec_t d;
4165 int c;
4167 for (c = 0;c < (int)(sizeof(irisvecs)/sizeof(irisvecs[0]));c++)
4168 {
4169 p[0] = point[0] + irisvecs[c][0] * r_hdr_irisadaptation_radius.value;
4170 p[1] = point[1] + irisvecs[c][1] * r_hdr_irisadaptation_radius.value;
4171 p[2] = point[2] + irisvecs[c][2] * r_hdr_irisadaptation_radius.value;
4175 if (d > 0)
4177 }
4178 brightness *= 1.0f / c;
4179 brightness += 0.00001f; // make sure it's never zero
4183 if (current < goal)
4185 else if (current > goal)
4187 if (fabs(r_hdr_irisadaptation_value.value - current) > 0.0001f)
4189 }
4190 else if (r_hdr_irisadaptation_value.value != 1.0f)
4192}
static float irisvecs[7][3]
Definition gl_rmain.c:4150
#define VectorLength(a)
Definition mathlib.h:108
void R_CompleteLightPoint(float *ambient, float *diffuse, float *lightdir, const vec3_t p, const int flags, float lightmapintensity, float ambientintensity)
Definition r_shadow.c:6027
#define LP_DYNLIGHT
Definition r_shadow.h:194
#define LP_LIGHTMAP
Definition r_shadow.h:192
#define LP_RTWORLD
Definition r_shadow.h:193
double realframetime
Definition client.h:872
float ambientintensity
Definition render.h:389
vec3_t forward
Definition render.h:268
static vec3_t forward
Definition sv_user.c:305

Referenced by CL_UpdateScreen().

◆ R_InitShaderModeInfo()

static void R_InitShaderModeInfo ( void  )
static

Definition at line 987 of file gl_rmain.c.

988{
989 int i, language;
991 // we have a bunch of things to compute that weren't calculated at engine compile time - all filenames should have a crc of the builtin strings to prevent accidental overrides (any customization must be updated to match engine)
993 {
994 for (i = 0; i < SHADERMODE_COUNT; i++)
995 {
996 char filename[MAX_QPATH];
998 modeinfo->builtinstring = R_ShaderStrCat(modeinfo->builtinshaderstrings);
999 modeinfo->builtincrc = CRC_Block((const unsigned char *)modeinfo->builtinstring, strlen(modeinfo->builtinstring));
1000 dpsnprintf(filename, sizeof(filename), "%s/%s_crc%i.%s", modeinfo->extension, modeinfo->sourcebasename, modeinfo->builtincrc, modeinfo->extension);
1001 modeinfo->filename = Mem_strdup(r_main_mempool, filename);
1002 }
1003 }
1004}
unsigned short CRC_Block(const unsigned char *data, size_t size)
Definition com_crc16.c:75
static char * R_ShaderStrCat(const char **strings)
Definition gl_rmain.c:965
#define Mem_strdup(pool, s)
Definition zone.h:97

Referenced by GL_Main_Init().

◆ R_LoadCubemap()

static rtexture_t * R_LoadCubemap ( const char basename)
static

Definition at line 2907 of file gl_rmain.c.

2908{
2909 int i, j, cubemapsize, forcefilter;
2910 unsigned char *cubemappixels, *image_buffer;
2912 char name[256];
2913
2914 // HACK: if the cubemap name starts with a !, the cubemap is nearest-filtered
2916 if (basename && basename[0] == '!')
2917 {
2918 basename++;
2920 }
2921 // must start 0 so the first loadimagepixels has no requested width/height
2922 cubemapsize = 0;
2925 // keep trying different suffix groups (posx, px, rt) until one loads
2926 for (j = 0;j < 3 && !cubemappixels;j++)
2927 {
2928 // load the 6 images in the suffix group
2929 for (i = 0;i < 6;i++)
2930 {
2931 // generate an image name based on the base and and suffix
2932 dpsnprintf(name, sizeof(name), "%s%s", basename, suffix[j][i].suffix);
2933 // load it
2934 if ((image_buffer = loadimagepixelsbgra(name, false, false, false, NULL)))
2935 {
2936 // an image loaded, make sure width and height are equal
2938 {
2939 // if this is the first image to load successfully, allocate the cubemap memory
2940 if (!cubemappixels && image_width >= 1)
2941 {
2943 // note this clears to black, so unavailable sides are black
2945 }
2946 // copy the image with any flipping needed by the suffix (px and posx types don't need flipping)
2947 if (cubemappixels)
2949 }
2950 else
2951 Con_Printf("Cubemap image \"%s\" (%ix%i) is not square, OpenGL requires square cubemaps.\n", name, image_width, image_height);
2952 // free the image
2954 }
2955 }
2956 }
2957 // if a cubemap loaded, upload it
2958 if (cubemappixels)
2959 {
2961 Con_Printf("loading cubemap \"%s\"\n", basename);
2962
2965 }
2966 else
2967 {
2968 Con_DPrintf("failed to load cubemap \"%s\"\n", basename);
2970 {
2971 Con_Printf("(tried tried images ");
2972 for (j = 0;j < 3;j++)
2973 for (i = 0;i < 6;i++)
2974 Con_Printf("%s\"%s%s.tga\"", j + i > 0 ? ", " : "", basename, suffix[j][i].suffix);
2975 Con_Print(" and was unable to find any of them).\n");
2976 }
2977 }
2978 return cubemaptexture;
2979}
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1450
static int componentorder[4]
Definition gl_rmain.c:2905
static suffixinfo_t suffix[3][6]
Definition gl_rmain.c:2877
cvar_t gl_texturecompression_lightcubemaps
Definition gl_textures.c:46
cvar_t gl_texturecompression
Definition gl_textures.c:37
cvar_t developer_loading
Definition host.c:53
int image_height
Definition image.c:10
void Image_CopyMux(unsigned char *outpixels, const unsigned char *inpixels, int inputwidth, int inputheight, qbool inputflipx, qbool inputflipy, qbool inputflipdiagonal, int numoutputcomponents, int numinputcomponents, int *outputinputcomponentindices)
Definition image.c:24
#define TEXF_FORCENEAREST
Definition r_textures.h:17
#define TEXF_COMPRESS
Definition r_textures.h:23
@ TEXTYPE_SRGB_BGRA
Definition r_textures.h:73
qbool sRGB3D
Definition vid.h:83

Referenced by R_GetCubemap().

◆ R_LoadQWSkin()

static void R_LoadQWSkin ( r_qwskincache_t cache,
const char skinname 
)
static

Definition at line 6558 of file gl_rmain.c.

6559{
6560 int textureflags = (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_PICMIP;
6561 char name[MAX_QPATH];
6562 skinframe_t *skinframe;
6563 unsigned char pixels[296*194];
6564 dp_strlcpy(cache->name, skinname, sizeof(cache->name));
6565 dpsnprintf(name, sizeof(name), "skins/%s.pcx", cache->name);
6567 Con_Printf("loading %s\n", name);
6568 skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, false);
6569 if (!skinframe || !skinframe->base)
6570 {
6571 unsigned char *f;
6572 fs_offset_t filesize;
6573 skinframe = NULL;
6574 f = FS_LoadFile(name, tempmempool, true, &filesize);
6575 if (f)
6576 {
6577 if (LoadPCX_QWSkin(f, (int)filesize, pixels, 296, 194))
6579 Mem_Free(f);
6580 }
6581 }
6582 cache->skinframe = skinframe;
6583}
int64_t fs_offset_t
Definition fs.h:37
skinframe_t * R_SkinFrame_LoadInternalQuake(const char *name, int textureflags, int loadpantsandshirt, int loadglowtexture, const unsigned char *skindata, int width, int height)
Definition gl_rmain.c:2615
skinframe_t * R_SkinFrame_Find(const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qbool add)
Definition gl_rmain.c:2239
GLint GLenum GLenum GLvoid * pixels
Definition glquake.h:705
qbool LoadPCX_QWSkin(const unsigned char *f, int filesize, unsigned char *pixels, int outwidth, int outheight)
Definition image.c:286
cvar_t r_mipskins
#define TEXF_PICMIP
Definition r_textures.h:21

Referenced by R_GetCurrentTexture().

◆ R_Main_FreeViewCache()

◆ R_Main_ResizeViewCache()

static void R_Main_ResizeViewCache ( void  )
static

Definition at line 3010 of file gl_rmain.c.

3011{
3012 int numentities = r_refdef.scene.numentities;
3017 if (r_refdef.viewcache.maxentities < numentities)
3018 {
3019 r_refdef.viewcache.maxentities = numentities;
3023 }
3024 if (r_refdef.viewcache.world_numclusters != numclusters)
3025 {
3026 r_refdef.viewcache.world_numclusters = numclusters;
3031 }
3032 if (r_refdef.viewcache.world_numleafs != numleafs)
3033 {
3038 }
3039 if (r_refdef.viewcache.world_numsurfaces != numsurfaces)
3040 {
3041 r_refdef.viewcache.world_numsurfaces = numsurfaces;
3045 }
3046}
int num_pvsclusterbytes

Referenced by R_View_Update().

◆ R_Mesh_AddBrushMeshFromPlanes()

void R_Mesh_AddBrushMeshFromPlanes ( rmesh_t mesh,
int  numplanes,
mplane_t planes 
)

Definition at line 6400 of file gl_rmain.c.

6401{
6402 int planenum, planenum2;
6403 int w;
6404 int tempnumpoints;
6405 mplane_t *plane, *plane2;
6406 double maxdist;
6407 double temppoints[2][256*3];
6408 // figure out how large a bounding box we need to properly compute this brush
6409 maxdist = 0;
6410 for (w = 0;w < numplanes;w++)
6411 maxdist = max(maxdist, fabs(planes[w].dist));
6412 // now make it large enough to enclose the entire brush, and round it off to a reasonable multiple of 1024
6413 maxdist = floor(maxdist * (4.0 / 1024.0) + 1) * 1024.0;
6414 for (planenum = 0, plane = planes;planenum < numplanes;planenum++, plane++)
6415 {
6416 w = 0;
6417 tempnumpoints = 4;
6418 PolygonD_QuadForPlane(temppoints[w], plane->normal[0], plane->normal[1], plane->normal[2], plane->dist, maxdist);
6420 {
6421 if (planenum2 == planenum)
6422 continue;
6423 PolygonD_Divide(tempnumpoints, temppoints[w], plane2->normal[0], plane2->normal[1], plane2->normal[2], plane2->dist, R_MESH_PLANE_DIST_EPSILON, 0, NULL, NULL, 256, temppoints[!w], &tempnumpoints, NULL);
6424 w = !w;
6425 }
6426 if (tempnumpoints < 3)
6427 continue;
6428 // generate elements forming a triangle fan for this polygon
6430 }
6431}
#define R_MESH_PLANE_DIST_EPSILON
Definition gl_rmain.c:6399
static void R_Mesh_AddPolygon3d(rmesh_t *mesh, int numvertices, double *vertex3d)
Definition gl_rmain.c:6378
void PolygonD_QuadForPlane(double *outpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double quadsize)
Definition polygon.c:54
void PolygonD_Divide(int innumpoints, const double *inpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double epsilon, int outfrontmaxpoints, double *outfrontpoints, int *neededfrontpoints, int outbackmaxpoints, double *outbackpoints, int *neededbackpoints, int *oncountpointer)
Definition polygon.c:245

◆ R_Mesh_AddPolygon3d()

static void R_Mesh_AddPolygon3d ( rmesh_t mesh,
int  numvertices,
double vertex3d 
)
static

Definition at line 6378 of file gl_rmain.c.

6379{
6380 int i;
6381 int *e, element[3];
6382 element[0] = R_Mesh_AddVertex(mesh, vertex3d[0], vertex3d[1], vertex3d[2]);vertex3d += 3;
6383 element[1] = R_Mesh_AddVertex(mesh, vertex3d[0], vertex3d[1], vertex3d[2]);vertex3d += 3;
6384 e = mesh->element3i + mesh->numtriangles * 3;
6385 for (i = 0;i < numvertices - 2;i++, vertex3d += 3)
6386 {
6387 element[2] = R_Mesh_AddVertex(mesh, vertex3d[0], vertex3d[1], vertex3d[2]);
6388 if (mesh->numtriangles < mesh->maxtriangles)
6389 {
6390 *e++ = element[0];
6391 *e++ = element[1];
6392 *e++ = element[2];
6393 mesh->numtriangles++;
6394 }
6395 element[1] = element[2];
6396 }
6397}
static int R_Mesh_AddVertex(rmesh_t *mesh, float x, float y, float z)
Definition gl_rmain.c:6335
int numtriangles
Definition render.h:169
int * element3i
Definition render.h:170
int maxtriangles
Definition render.h:168

Referenced by R_Mesh_AddBrushMeshFromPlanes().

◆ R_Mesh_AddPolygon3f()

void R_Mesh_AddPolygon3f ( rmesh_t mesh,
int  numvertices,
float vertex3f 
)

Definition at line 6357 of file gl_rmain.c.

6358{
6359 int i;
6360 int *e, element[3];
6361 element[0] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);vertex3f += 3;
6362 element[1] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);vertex3f += 3;
6363 e = mesh->element3i + mesh->numtriangles * 3;
6364 for (i = 0;i < numvertices - 2;i++, vertex3f += 3)
6365 {
6366 element[2] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);
6367 if (mesh->numtriangles < mesh->maxtriangles)
6368 {
6369 *e++ = element[0];
6370 *e++ = element[1];
6371 *e++ = element[2];
6372 mesh->numtriangles++;
6373 }
6374 element[1] = element[2];
6375 }
6376}

◆ R_Mesh_AddVertex()

static int R_Mesh_AddVertex ( rmesh_t mesh,
float  x,
float  y,
float  z 
)
static

Definition at line 6335 of file gl_rmain.c.

6336{
6337 int i;
6338 float *vertex3f;
6339 float v[3];
6340 VectorSet(v, x, y, z);
6341 for (i = 0, vertex3f = mesh->vertex3f;i < mesh->numvertices;i++, vertex3f += 3)
6342 if (VectorDistance2(v, vertex3f) < mesh->epsilon2)
6343 break;
6344 if (i == mesh->numvertices)
6345 {
6346 if (mesh->numvertices < mesh->maxvertices)
6347 {
6348 VectorCopy(v, vertex3f);
6349 mesh->numvertices++;
6350 }
6351 return mesh->numvertices;
6352 }
6353 else
6354 return i;
6355}
GLubyte GLubyte GLubyte z
Definition glquake.h:781
#define VectorDistance2(a, b)
Definition mathlib.h:106
float epsilon2
Definition render.h:172
float * vertex3f
Definition render.h:160
int maxvertices
Definition render.h:158
int numvertices
Definition render.h:159

Referenced by R_Mesh_AddPolygon3d(), and R_Mesh_AddPolygon3f().

◆ R_ModulateColors()

void R_ModulateColors ( float in,
float out,
int  verts,
float  r,
float  g,
float  b 
)

Definition at line 321 of file gl_rmain.c.

322{
323 int i;
324 for (i = 0;i < verts;i++)
325 {
326 out[0] = in[0] * r;
327 out[1] = in[1] * g;
328 out[2] = in[2] * b;
329 out[3] = in[3];
330 in += 4;
331 out += 4;
332 }
333}

◆ R_MotionBlurView()

static void R_MotionBlurView ( int  viewfbo,
rtexture_t viewdepthtexture,
rtexture_t viewcolortexture,
int  viewx,
int  viewy,
int  viewwidth,
int  viewheight 
)
static

Definition at line 5259 of file gl_rmain.c.

5260{
5262
5264 {
5265 // declare variables
5267 static float blur_average;
5268 static vec3_t blur_oldangles; // used to see how quickly the mouse is moving
5269
5270 // set a goal for the factoring
5277
5278 // from the goal, pick an averaged value between goal and last value
5281
5282 // enforce minimum amount of blur
5284
5285 //Con_Printf("motionblur: direct factor: %f, averaged factor: %f, velocity: %f, mouse accel: %f \n", blur_factor, blur_average, blur_velocity, blur_mouseaccel);
5286
5287 // calculate values into a standard alpha
5288 cl.motionbluralpha = 1 - exp(-
5289 (
5291 +
5293 )
5294 /
5295 max(0.0001, cl.time - cl.oldtime) // fps independent
5296 );
5297
5298 // randomization for the blur value to combat persistent ghosting
5301
5302 // apply the blur on top of the current view
5305 {
5307 GL_Color(1, 1, 1, cl.motionbluralpha);
5310 R_SetupShader_Generic(r_fb.ghosttexture, false, true, true);
5313 }
5314
5315 // updates old view angles for next pass
5317
5318 // copy view into the ghost texture
5321 r_fb.ghosttexture_valid = true;
5322 }
5323}
#define CSHIFT_DAMAGE
Definition client.h:513
void R_Mesh_CopyToTexture(rtexture_t *tex, int tx, int ty, int sx, int sy, int width, int height)
static void R_CalcTexCoordsForView(float x, float y, float w, float h, float tw, float th, float *texcoord2f)
Definition gl_rmain.c:4555
@ r_stat_bloom_copypixels
Definition r_stats.h:43
double oldtime
Definition client.h:869
vec3_t movement_velocity
Definition client.h:811
cshift_t cshifts[NUM_CSHIFTS]
Definition client.h:776
vec3_t viewangles
Definition client.h:787
double time
Definition client.h:869
float motionbluralpha
Definition client.h:883
float percent
Definition client.h:508
float ghosttexcoord2f[8]
Definition render.h:896
qbool envmap
Definition render.h:460

Referenced by R_RenderView().

◆ R_ProcessModelTextureSurfaceList()

static void R_ProcessModelTextureSurfaceList ( int  texturenumsurfaces,
const msurface_t **  texturesurfacelist,
qbool  writedepth,
qbool  depthonly,
qbool  prepass,
qbool  ui 
)
static

Definition at line 9014 of file gl_rmain.c.

9015{
9017 if (ui)
9019 else if (depthonly)
9021 else if (prepass)
9022 {
9024 return;
9027 else
9029 }
9033 return;
9035 {
9036 // in the deferred case, transparent surfaces were queued during prepass
9039 }
9040 else
9041 {
9042 // the alphatest check is to make sure we write depth for anything we skipped on the depth-only pass earlier
9044 }
9046}
qbool r_shadow_usingdeferredprepass
Definition r_shadow.c:64
static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:8623
static void R_ProcessTransparentTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:8969
static void R_DrawTextureSurfaceList_DepthOnly(int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:9001

Referenced by R_QueueModelSurfaceList().

◆ R_ProcessTransparentTextureSurfaceList()

static void R_ProcessTransparentTextureSurfaceList ( int  texturenumsurfaces,
const msurface_t **  texturesurfacelist 
)
static

Definition at line 8969 of file gl_rmain.c.

8970{
8971 // transparent surfaces get pushed off into the transparent queue
8972 int surfacelistindex;
8973 const msurface_t *surface;
8974 vec3_t tempcenter, center;
8976 {
8979 {
8980 tempcenter[0] = bound(surface->mins[0], rsurface.localvieworigin[0], surface->maxs[0]);
8981 tempcenter[1] = bound(surface->mins[1], rsurface.localvieworigin[1], surface->maxs[1]);
8982 tempcenter[2] = bound(surface->mins[2], rsurface.localvieworigin[2], surface->maxs[2]);
8983 }
8984 else
8985 {
8986 tempcenter[0] = (surface->mins[0] + surface->maxs[0]) * 0.5f;
8987 tempcenter[1] = (surface->mins[1] + surface->maxs[1]) * 0.5f;
8988 tempcenter[2] = (surface->mins[2] + surface->maxs[2]) * 0.5f;
8989 }
8991 if (rsurface.entity->transparent_offset) // transparent offset
8992 {
8996 }
8998 }
8999}
static void R_DrawSurface_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rmain.c:8887
#define RENDER_WORLDOBJECT
Definition protocol.h:363
@ TRANSPARENTSORT_SKY
Definition r_qshader.h:193
float transparent_offset
Definition client.h:341
vec3_t localvieworigin
Definition render.h:733

Referenced by R_ProcessModelTextureSurfaceList().

◆ R_QueueModelSurfaceList()

static void R_QueueModelSurfaceList ( entity_render_t ent,
int  numsurfaces,
const msurface_t **  surfacelist,
int  flagsmask,
qbool  writedepth,
qbool  depthonly,
qbool  prepass,
qbool  ui 
)
static

Definition at line 9048 of file gl_rmain.c.

9049{
9050 int i, j;
9053 // break the surface list down into batches by texture and use of lightmapping
9054 for (i = 0;i < numsurfaces;i = j)
9055 {
9056 j = i + 1;
9057 // texture is the base texture pointer, rsurface.texture is the
9058 // current frame/skin the texture is directing us to use (for example
9059 // if a model has 2 skins and it is on skin 1, then skin 0 tells us to
9060 // use skin 1 instead)
9061 texture = surfacelist[i]->texture;
9064 {
9065 // if this texture is not the kind we want, skip ahead to the next one
9066 for (;j < numsurfaces && texture == surfacelist[j]->texture;j++)
9067 ;
9068 continue;
9069 }
9070 if(depthonly || prepass)
9071 {
9075 // simply scan ahead until we find a different texture or lightmap state
9076 for (;j < numsurfaces && texture == surfacelist[j]->texture;j++)
9077 ;
9078 }
9079 else
9080 {
9081 rsurface.lightmaptexture = surfacelist[i]->lightmaptexture;
9084 // simply scan ahead until we find a different texture or lightmap state
9085 for (;j < numsurfaces && texture == surfacelist[j]->texture && rsurface.lightmaptexture == surfacelist[j]->lightmaptexture;j++)
9086 ;
9087 }
9088 // render the range of surfaces
9090 }
9092}
void R_FrameData_SetMark(void)
set a marker that allows you to discard the following temporary memory allocations
Definition gl_rmain.c:3589
void R_FrameData_ReturnToMark(void)
discard recent memory allocations (rewind to marker)
Definition gl_rmain.c:3596
static void R_ProcessModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
Definition gl_rmain.c:9014
#define MATERIALFLAG_NODRAW
Definition model_brush.h:96
struct rtexture_s * deluxemaptexture
the lighting direction texture fragment to use on the rendering mesh
struct rtexture_s * lightmaptexture
the lightmap texture fragment to use on the rendering mesh

Referenced by R_DrawModelSurfaces().

◆ R_RenderScene()

void R_RenderScene ( int  viewfbo,
rtexture_t viewdepthtexture,
rtexture_t viewcolortexture,
int  viewx,
int  viewy,
int  viewwidth,
int  viewheight 
)

Definition at line 5842 of file gl_rmain.c.

5843{
5844 qbool shadowmapping = false;
5845
5847 R_TimeReport("beginscene");
5848
5850
5851 R_UpdateFog();
5852
5853 // don't let sound skip if going slow
5855 S_ExtraUpdate ();
5856
5858
5860
5862
5864 R_TimeReport("skystartframe");
5865
5867 {
5868 // don't let sound skip if going slow
5870 S_ExtraUpdate ();
5871
5873 {
5876 R_TimeReport("worldsky");
5877 }
5878
5880 R_TimeReport("bmodelsky");
5881
5883 {
5884 // we have to force off the water clipping plane while rendering sky
5886 R_Sky();
5889 R_TimeReport("sky");
5890 }
5891 }
5892
5893 // save the framebuffer info for R_Shadow_RenderMode_Reset during this view render
5901
5905 R_TimeReport("preparelights");
5906
5907 // render all the shadowmaps that will be used for this view
5910 {
5913 R_TimeReport("shadowmaps");
5914 }
5915
5916 // render prepass deferred lighting if r_shadow_deferred is on, this produces light buffers that will be sampled in forward pass
5919
5920 // now we begin the forward pass of the view render
5922 {
5925 R_TimeReport("worlddepth");
5926 }
5927 if (r_depthfirst.integer >= 2)
5928 {
5931 R_TimeReport("modeldepth");
5932 }
5933
5935 {
5938 R_TimeReport("world");
5939 }
5940
5941 // don't let sound skip if going slow
5943 S_ExtraUpdate ();
5944
5945 R_DrawModels();
5947 R_TimeReport("models");
5948
5949 // don't let sound skip if going slow
5951 S_ExtraUpdate ();
5952
5954 {
5957 R_TimeReport("rtlights");
5958 }
5959
5960 // don't let sound skip if going slow
5962 S_ExtraUpdate ();
5963
5965 {
5968 R_TimeReport("modeldecals");
5969
5972 R_TimeReport("particles");
5973
5976 R_TimeReport("explosions");
5977 }
5978
5980 {
5982 {
5983 R_DrawLocs();
5985 R_TimeReport("showlocs");
5986 }
5987
5989 {
5990 R_DrawPortals();
5992 R_TimeReport("portals");
5993 }
5994
5995 if (r_showbboxes_client.value > 0)
5996 {
5999 R_TimeReport("clbboxes");
6000 }
6001 if (r_showbboxes.value > 0)
6002 {
6005 R_TimeReport("svbboxes");
6006 }
6007 }
6008
6010 {
6013 R_TimeReport("drawtrans");
6014 }
6015
6017 {
6020 R_TimeReport("worlddebug");
6023 R_TimeReport("modeldebug");
6024 }
6025
6027 {
6030 R_TimeReport("coronas");
6031 }
6032
6033 // don't let sound skip if going slow
6035 S_ExtraUpdate ();
6036}
void R_DrawParticles(void)
static int R_DrawBrushModelsSky(void)
only used if skyrendermasked, and normally returns false
Definition gl_rmain.c:4066
static void R_DrawModelsDebug(void)
Definition gl_rmain.c:4120
static void R_DrawLocs(void)
Definition gl_rmain.c:9157
void R_UpdateFog(void)
Definition gl_rmain.c:5404
static void R_DrawModels(void)
Definition gl_rmain.c:4086
cvar_t cl_locs_show
Definition cl_main.c:96
void R_SetupView(qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4392
int r_shadow_shadowmapatlas_modelshadows_size
Definition r_shadow.c:69
static void R_DrawModelDecals(void)
Definition gl_rmain.c:9775
static void R_DrawModelsDepth(void)
Definition gl_rmain.c:4105
static void R_DrawEntityBBoxes(prvm_prog_t *prog)
Definition gl_rmain.c:6156
void R_DrawPortals(void)
Definition gl_rsurf.c:381
void Matrix4x4_CreateTranslate(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:584
void R_MeshQueue_BeginScene(void)
Definition meshqueue.c:26
void R_MeshQueue_RenderTransparent(void)
Definition meshqueue.c:62
void R_DrawExplosions(void)
int r_shadow_viewx
Definition r_shadow.c:127
void R_Shadow_DrawShadowMaps(void)
Definition r_shadow.c:4212
rtexture_t * r_shadow_viewdepthtexture
Definition r_shadow.c:125
int r_shadow_viewfbo
Definition r_shadow.c:124
void R_Shadow_PrepareLights(void)
Definition r_shadow.c:4039
qbool R_Shadow_ShadowMappingEnabled(void)
Definition r_shadow.c:378
void R_Shadow_PrepareModelShadows(void)
Definition r_shadow.c:4255
rtexture_t * r_shadow_viewcolortexture
Definition r_shadow.c:126
int r_shadow_viewy
Definition r_shadow.c:128
void R_Shadow_DrawCoronas(void)
Definition r_shadow.c:4541
void R_Shadow_DrawLights(void)
Definition r_shadow.c:4239
void R_Shadow_DrawPrepass(void)
Definition r_shadow.c:3966
int r_shadow_viewwidth
Definition r_shadow.c:129
int r_shadow_viewheight
Definition r_shadow.c:130
void R_Sky(void)
Definition r_sky.c:403
void R_SkyStartFrame(void)
Definition r_sky.c:57
int r_timereport_active
Definition r_stats.c:189
void R_TimeReport(const char *desc)
Definition r_stats.c:193
@ r_stat_renders
Definition r_stats.h:11
void S_ExtraUpdate(void)
Definition snd_main.c:2245
csqc_vidvars_t csqc_vidvars
Definition client.h:835
qbool drawworld
Definition client.h:707
qbool extraupdate
whether to call S_ExtraUpdate during render to reduce sound chop
Definition render.h:354

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_RenderTarget_FreeUnused()

void R_RenderTarget_FreeUnused ( qbool  force)

Definition at line 4531 of file gl_rmain.c.

4532{
4533 unsigned int i, j, end;
4534 end = (unsigned int)Mem_ExpandableArray_IndexRange(&r_fb.rendertargets); // checked
4535 for (i = 0; i < end; i++)
4536 {
4538 // free resources for rendertargets that have not been used for a while
4539 // (note: this check is run after the frame render, so any targets used
4540 // this frame will not be affected even at low framerates)
4541 if (r && (host.realtime - r->lastusetime > 0.2 || force))
4542 {
4543 if (r->fbo)
4545 for (j = 0; j < sizeof(r->colortexture) / sizeof(r->colortexture[0]); j++)
4546 if (r->colortexture[j])
4547 R_FreeTexture(r->colortexture[j]);
4548 if (r->depthtexture)
4549 R_FreeTexture(r->depthtexture);
4551 }
4552 }
4553}
void R_Mesh_DestroyFramebufferObject(int fbo)
host_static_t host
Definition host.c:41
double realtime
Definition host.h:37

Referenced by gl_main_shutdown(), and SCR_DrawScreen().

◆ R_RenderTarget_Get()

r_rendertarget_t * R_RenderTarget_Get ( int  texturewidth,
int  textureheight,
textype_t  depthtextype,
qbool  depthisrenderbuffer,
textype_t  colortextype0,
textype_t  colortextype1,
textype_t  colortextype2,
textype_t  colortextype3 
)

Definition at line 4572 of file gl_rmain.c.

4573{
4574 unsigned int i, j, end;
4576 char vabuf[256];
4577 // first try to reuse an existing slot if possible
4578 end = (unsigned int)Mem_ExpandableArray_IndexRange(&r_fb.rendertargets); // checked
4579 for (i = 0; i < end; i++)
4580 {
4582 if (r && r->lastusetime != host.realtime && r->texturewidth == texturewidth && r->textureheight == textureheight && r->depthtextype == depthtextype && r->colortextype[0] == colortextype0 && r->colortextype[1] == colortextype1 && r->colortextype[2] == colortextype2 && r->colortextype[3] == colortextype3)
4583 break;
4584 }
4585 if (i == end)
4586 {
4587 // no unused exact match found, so we have to make one in the first unused slot
4589 r->texturewidth = texturewidth;
4590 r->textureheight = textureheight;
4591 r->colortextype[0] = colortextype0;
4592 r->colortextype[1] = colortextype1;
4593 r->colortextype[2] = colortextype2;
4594 r->colortextype[3] = colortextype3;
4595 r->depthtextype = depthtextype;
4596 r->depthisrenderbuffer = depthisrenderbuffer;
4597 for (j = 0; j < 4; j++)
4598 if (r->colortextype[j])
4599 r->colortexture[j] = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "rendertarget%i_%i_type%i", i, j, (int)r->colortextype[j]), r->texturewidth, r->textureheight, NULL, r->colortextype[j], TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
4600 if (r->depthtextype)
4601 {
4602 if (r->depthisrenderbuffer)
4603 r->depthtexture = R_LoadTextureRenderBuffer(r_main_texturepool, va(vabuf, sizeof(vabuf), "renderbuffer%i_depth_type%i", i, (int)r->depthtextype), r->texturewidth, r->textureheight, r->depthtextype);
4604 else
4605 r->depthtexture = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "rendertarget%i_depth_type%i", i, (int)r->depthtextype), r->texturewidth, r->textureheight, NULL, r->depthtextype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
4606 }
4607 r->fbo = R_Mesh_CreateFramebufferObject(r->depthtexture, r->colortexture[0], r->colortexture[1], r->colortexture[2], r->colortexture[3]);
4608 }
4610 r_refdef.stats[r_stat_rendertargets_pixels] += r->texturewidth * r->textureheight;
4611 r->lastusetime = host.realtime;
4612 R_CalcTexCoordsForView(0, 0, r->texturewidth, r->textureheight, r->texturewidth, r->textureheight, r->texcoord2f);
4613 return r;
4614}
char * va(char *buf, size_t buflen, const char *format,...)
Definition common.c:972
int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4)
Definition gl_backend.c:959
rtexture_t * R_LoadTextureRenderBuffer(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, textype_t textype)
@ r_stat_rendertargets_used
Definition r_stats.h:45
@ r_stat_rendertargets_pixels
Definition r_stats.h:46

Referenced by R_Bloom_MakeTexture(), R_Bloom_StartFrame(), R_Envmap_f(), and R_Water_ProcessPlanes().

◆ R_RenderView()

void R_RenderView ( int  fbo,
rtexture_t depthtexture,
rtexture_t colortexture,
int  x,
int  y,
int  width,
int  height 
)

Definition at line 5645 of file gl_rmain.c.

5646{
5648 int viewfbo = 0;
5653
5654 // finish any 2D rendering that was queued
5655 DrawQ_Finish();
5656
5658 R_TimeReport("start");
5659 r_textureframe++; // used only by R_GetCurrentTexture
5660 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
5661
5664
5667 else if (r_sortentities.integer)
5669
5671
5672 /* adjust for stereo display */
5673 if(R_Stereo_Active())
5674 {
5677 }
5678
5680 {
5681 // TODO: FIXME: move this into its own backend function maybe? [2/5/2008 Andreas]
5684 R_TimeReport("depthclear");
5685
5686 r_refdef.view.showdebug = false;
5687
5688 r_fb.water.enabled = false;
5690
5692
5694
5696 return;
5697 }
5698
5699 if (!r_refdef.scene.entities || r_refdef.view.width * r_refdef.view.height == 0 || !r_renderview.integer || cl_videoplaying/* || !r_refdef.scene.worldmodel*/)
5700 {
5702 return;
5703 }
5704
5708
5710
5712 // in sRGB fallback, behave similar to true sRGB: convert this
5713 // value from linear to sRGB
5715
5717
5719
5720 // this will set up r_fb.rt_screen
5722
5723 // apply bloom brightness offset
5724 if(r_fb.rt_bloom)
5726
5728 if (skipblend)
5729 {
5730 // Render to the screen right away.
5731 viewfbo = fbo;
5732 viewdepthtexture = depthtexture;
5733 viewcolortexture = colortexture;
5734 viewx = x;
5735 viewy = y;
5736 viewwidth = width;
5738 }
5739 else if (r_fb.rt_screen)
5740 {
5741 // R_Bloom_StartFrame probably set up an fbo for us to render into, it will be rendered to the window later in R_BlendView
5745 viewx = 0;
5746 viewy = 0;
5749 }
5750
5752
5755 R_TimeReport("viewsetup");
5756
5758
5759 // clear the whole fbo every frame - otherwise the driver will consider
5760 // it to be an inter-frame texture and stall in multi-gpu configurations
5761 if (r_fb.rt_screen)
5762 GL_ScissorTest(false);
5765 R_TimeReport("viewclear");
5766
5767 r_refdef.view.clear = true;
5768
5769 r_refdef.view.showdebug = true;
5770
5773 R_TimeReport("visibility");
5774
5777 R_TimeReport("animcache");
5778
5780 // R_Shadow_UpdateBounceGridTexture called R_TimeReport a few times internally, so we don't need to do that here.
5781
5783 if (r_fb.water.enabled)
5785
5786 // for the actual view render we use scissoring a fair amount, so scissor
5787 // test needs to be on
5788 if (r_fb.rt_screen)
5789 GL_ScissorTest(true);
5793
5794 // postprocess uses textures that are not aligned with the viewport we're rendering, so no scissoring
5795 GL_ScissorTest(false);
5796
5798 if (!skipblend)
5799 R_BlendView(viewcolortexture, fbo, depthtexture, colortexture, x, y, width, height);
5801 R_TimeReport("blendview");
5802
5804
5806
5807 // go back to 2d rendering
5808 DrawQ_Start();
5809}
int r_stereo_side
Definition cl_screen.c:1582
cvar_t r_stereo_angle
Definition cl_screen.c:86
void R_ClearScreen(qbool fogcolor)
Definition cl_screen.c:1563
cvar_t r_stereo_separation
Definition cl_screen.c:79
int cl_videoplaying
Definition cl_video.c:458
void DrawQ_Start(void)
Definition gl_draw.c:788
void DrawQ_Finish(void)
Definition gl_draw.c:1454
cvar_t r_renderview
Definition gl_backend.c:12
void GL_Scissor(int x, int y, int width, int height)
void GL_ScissorTest(int state)
void R_RenderView_UpdateViewVectors(void)
Definition gl_rmain.c:4520
static void R_BlendView(rtexture_t *viewcolortexture, int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height)
Definition gl_rmain.c:5325
static void R_SortEntities(void)
Definition gl_rmain.c:5628
void R_RenderScene(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5842
void R_RenderWaterPlanes(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5811
void R_ResetViewRendering3D(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4490
static qbool R_BlendView_IsTrivial(int viewwidth, int viewheight, int width, int height)
Definition gl_rmain.c:5232
static void R_Bloom_StartFrame(void)
Definition gl_rmain.c:5027
void V_MakeViewIsometric(void)
Definition view.c:968
static void R_MotionBlurView(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5259
cvar_t v_isometric
Definition view.c:97
static void R_View_Update(const int *myscissor)
Definition gl_rmain.c:4382
qbool R_CompileShader_CheckStaticParms(void)
Definition gl_rmain.c:861
void R_AnimCache_ClearCache(void)
clear the animcache pointers on all known render entities
Definition gl_rmain.c:3770
static void R_Water_StartFrame(int viewwidth, int viewheight)
Definition gl_rmain.c:4616
void R_AnimCache_CacheVisibleEntities(void)
generate animcache data for all entities marked visible
Definition gl_rmain.c:3882
#define GL_DEPTH_BUFFER_BIT
Definition glquake.h:168
#define Image_sRGBFloatFromLinearFloat(c)
Definition image.h:68
void R_Shadow_UpdateBounceGridTexture(void)
Definition r_shadow.c:2755
void R_Shadow_UpdateWorldLightSelection(void)
Definition r_shadow.c:5302
int useperspective
if turned off it renders an ortho view
Definition render.h:280
matrix4x4_t matrix
Definition render.h:266
rtexture_t * depthtexture
Definition render.h:840
int numwaterplanes
Definition render.h:873
cvar_t vid_sRGB_fallback
Definition vid_shared.c:159
cvar_t vid_sRGB
Definition vid_shared.c:158

Referenced by R_Envmap_f(), SCR_DrawScreen(), and VM_CL_R_RenderScene().

◆ R_RenderView_UpdateViewVectors()

void R_RenderView_UpdateViewVectors ( void  )

Definition at line 4520 of file gl_rmain.c.

4521{
4522 // break apart the view matrix into vectors for various purposes
4523 // it is important that this occurs outside the RenderScene function because that can be called from reflection renders, where the vectors come out wrong
4524 // however the r_refdef.view.origin IS updated in RenderScene intentionally - otherwise the sky renders at the wrong origin, etc
4527 // make an inverted copy of the view matrix for tracking sprites
4529}
int Matrix4x4_Invert_Full(matrix4x4_t *out, const matrix4x4_t *in1)
Definition matrixlib.c:145
void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3])
Definition matrixlib.c:939
vec3_t left
Definition render.h:269
vec3_t right
Definition render.h:270
matrix4x4_t inverse_matrix
Definition render.h:266

Referenced by CL_VM_UpdateView(), R_RenderView(), and R_Water_ProcessPlanes().

◆ R_RenderWaterPlanes()

void R_RenderWaterPlanes ( int  viewfbo,
rtexture_t viewdepthtexture,
rtexture_t viewcolortexture,
int  viewx,
int  viewy,
int  viewwidth,
int  viewheight 
)

Definition at line 5811 of file gl_rmain.c.

5812{
5814 {
5817 R_TimeReport("waterworld");
5818 }
5819
5820 // don't let sound skip if going slow
5822 S_ExtraUpdate ();
5823
5826 R_TimeReport("watermodels");
5827
5829 {
5832 R_TimeReport("waterscenes");
5833 }
5834}
static void R_DrawModelsAddWaterPlanes(void)
Definition gl_rmain.c:4135
static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4765

Referenced by R_RenderView().

◆ R_ResetViewRendering2D()

void R_ResetViewRendering2D ( int  viewfbo,
rtexture_t viewdepthtexture,
rtexture_t viewcolortexture,
int  viewx,
int  viewy,
int  viewwidth,
int  viewheight 
)

Definition at line 4485 of file gl_rmain.c.

4486{
4488}
void R_ResetViewRendering2D_Common(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight, float x2, float y2)
Definition gl_rmain.c:4447

Referenced by R_BlendView(), and R_MotionBlurView().

◆ R_ResetViewRendering2D_Common()

void R_ResetViewRendering2D_Common ( int  viewfbo,
rtexture_t viewdepthtexture,
rtexture_t viewcolortexture,
int  viewx,
int  viewy,
int  viewwidth,
int  viewheight,
float  x2,
float  y2 
)

Definition at line 4447 of file gl_rmain.c.

4448{
4449 r_viewport_t viewport;
4450 int viewy_adjusted;
4451
4453
4454 // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom.
4455 // Unless the render target is a FBO...
4457
4460 R_SetViewport(&viewport);
4461 GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
4462 GL_Color(1, 1, 1, 1);
4465 GL_ScissorTest(false);
4466 GL_DepthMask(false);
4467 GL_DepthRange(0, 1);
4468 GL_DepthTest(false);
4472 GL_PolygonOffset(0, 0);
4473 switch(vid.renderpath)
4474 {
4475 case RENDERPATH_GL32:
4476 case RENDERPATH_GLES2:
4478 break;
4479 }
4481
4483}
void GL_DepthFunc(int state)
#define GL_POLYGON_OFFSET_FILL
Definition glquake.h:182
#define GL_LEQUAL
Definition glquake.h:161

Referenced by DrawQ_Start(), and R_ResetViewRendering2D().

◆ R_ResetViewRendering3D()

void R_ResetViewRendering3D ( int  viewfbo,
rtexture_t viewdepthtexture,
rtexture_t viewcolortexture,
int  viewx,
int  viewy,
int  viewwidth,
int  viewheight 
)

◆ R_SelectScene()

void R_SelectScene ( r_refdef_scene_type_t  scenetype)

Definition at line 5581 of file gl_rmain.c.

5581 {
5582 if( scenetype != r_currentscenetype ) {
5583 // store the old scenetype
5586 // move in the new scene
5588 }
5589}

Referenced by MP_Draw(), and MVM_error_cmd().

◆ R_SetupShader_DeferredLight()

void R_SetupShader_DeferredLight ( const rtlight_t rtlight)

Definition at line 2090 of file gl_rmain.c.

2091{
2092 // select a permutation of the lighting shader appropriate to this
2093 // combination of texture, entity, light source, and fogging, only use the
2094 // minimum features necessary to avoid wasting rendering time in the
2095 // fragment shader on features that are not being used
2096 uint64_t permutation = 0;
2097 unsigned int mode = 0;
2098 const float *lightcolorbase = rtlight->currentcolor;
2099 float ambientscale = rtlight->ambientscale;
2100 float diffusescale = rtlight->diffusescale;
2101 float specularscale = rtlight->specularscale;
2102 // this is the location of the light in view space
2104 // this transforms from view space (camera) to light space (cubemap)
2107 float viewtolight16f[16];
2108 // light source
2110 if (rtlight->currentcubemap != r_texture_whitecube)
2111 permutation |= SHADERPERMUTATION_CUBEFILTER;
2112 if (diffusescale > 0)
2113 permutation |= SHADERPERMUTATION_DIFFUSE;
2114 if (specularscale > 0 && r_shadow_gloss.integer > 0)
2117 {
2118 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
2120 permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT;
2121
2123 permutation |= SHADERPERMUTATION_DEPTHRGB;
2124 }
2126 GL_AlphaToCoverage(false);
2131 switch(vid.renderpath)
2132 {
2133 case RENDERPATH_GL32:
2134 case RENDERPATH_GLES2:
2146
2152 break;
2153 }
2154}
void GL_AlphaToCoverage(qbool state)
rtexture_t * r_shadow_prepassgeometrynormalmaptexture
Definition r_shadow.c:120
qbool r_shadow_shadowmapvsdct
Definition r_shadow.c:57
rtexture_t * r_shadow_attenuationgradienttexture
Definition r_shadow.c:108
float r_shadow_lightshadowmap_parameters[4]
Definition r_shadow.c:41
qbool r_shadow_usingshadowmap2d
Definition r_shadow.c:37
float r_shadow_lightshadowmap_texturescale[4]
Definition r_shadow.c:40
rtexture_t * r_shadow_shadowmapvsdcttexture
Definition r_shadow.c:112
rtexture_t * r_shadow_shadowmap2ddepthtexture
Definition r_shadow.c:111
rtexture_t * r_shadow_shadowmap2ddepthbuffer
Definition r_shadow.c:110
#define SHADERPERMUTATION_SPECULAR
(lightsource or deluxemapping) render specular effects
Definition render.h:86
@ SHADERMODE_DEFERREDLIGHTSOURCE
(deferred) use directional pixel shading from light source (rtlight) on screenspace geometry buffers
Definition render.h:68
#define SHADERPERMUTATION_DEPTHRGB
read/write depth values in RGB color coded format for older hardware without depth samplers
Definition render.h:101
#define SHADERPERMUTATION_SHADOWMAPVSDCT
(lightsource) use virtual shadow depth cube texture for shadowmap indexing
Definition render.h:92
#define SHADERPERMUTATION_SHADOWMAP2D
(lightsource) use shadowmap texture as light filter
Definition render.h:91
#define SHADERPERMUTATION_CUBEFILTER
(lightsource) use cubemap light filter
Definition render.h:83
#define SHADERPERMUTATION_DIFFUSE
(lightsource) whether to use directional shading
Definition render.h:73
float screentodepth[2]
used by deferred renderer to calculate linear depth from device depth coordinates
Definition render.h:250
matrix4x4_t viewmatrix
actual matrix for rendering (transforms to viewspace)
Definition render.h:241
vec_t ambientscale
ambient intensity to render
Definition client.h:129
rtexture_t * currentcubemap
this is R_GetCubemap(rtlight->cubemapname)
Definition client.h:154
vec3_t currentcolor
Definition client.h:148
vec_t specularscale
specular intensity to render
Definition client.h:133
vec3_t shadoworigin
used only for casting shadows
Definition client.h:139
matrix4x4_t matrix_lighttoworld
matrix for transforming light filter coordinates to world coordinates
Definition client.h:111
vec_t diffusescale
diffuse intensity to render
Definition client.h:131

Referenced by R_Shadow_RenderMode_DrawDeferredLight().

◆ R_SetupShader_DepthOrShadow()

void R_SetupShader_DepthOrShadow ( qbool  notrippy,
qbool  depthrgb,
qbool  skeletal 
)

Definition at line 1492 of file gl_rmain.c.

1493{
1494 uint64_t permutation = 0;
1495 if (r_trippy.integer && !notrippy)
1496 permutation |= SHADERPERMUTATION_TRIPPY;
1497 if (depthrgb)
1498 permutation |= SHADERPERMUTATION_DEPTHRGB;
1499 if (skeletal)
1500 permutation |= SHADERPERMUTATION_SKELETAL;
1501
1503 GL_AlphaToCoverage(false);
1504 switch (vid.renderpath)
1505 {
1506 case RENDERPATH_GL32:
1507 case RENDERPATH_GLES2:
1509#ifndef USE_GLES2 /* FIXME: GLES3 only */
1511#endif
1512 break;
1513 }
1514}
#define GL_UNIFORM_BUFFER
Definition glquake.h:412
#define SHADERPERMUTATION_SKELETAL
(skeletal models) use skeletal matrices to deform vertices (gpu-skinning)
Definition render.h:103
@ SHADERMODE_DEPTH_OR_SHADOW
(depthfirst/shadows) vertex shader only
Definition render.h:54
#define SHADERPERMUTATION_TRIPPY
use trippy vertex shader effect
Definition render.h:100
const r_meshbuffer_t * batchskeletaltransform3x4buffer
Definition render.h:713
int batchskeletaltransform3x4size
Definition render.h:715
int batchskeletaltransform3x4offset
Definition render.h:714

Referenced by R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_Sky(), R_Shadow_ClearShadowMapTexture(), and R_Shadow_RenderMode_ShadowMap().

◆ R_SetupShader_Generic()

void R_SetupShader_Generic ( rtexture_t t,
qbool  usegamma,
qbool  notrippy,
qbool  suppresstexalpha 
)

Definition at line 1460 of file gl_rmain.c.

1461{
1462 uint64_t permutation = 0;
1463 if (r_trippy.integer && !notrippy)
1464 permutation |= SHADERPERMUTATION_TRIPPY;
1465 permutation |= SHADERPERMUTATION_VIEWTINT;
1466 if (t)
1467 permutation |= SHADERPERMUTATION_DIFFUSE;
1469 permutation |= SHADERPERMUTATION_GAMMARAMPS;
1470 if (suppresstexalpha)
1471 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1473 GL_AlphaToCoverage(false);
1474 switch (vid.renderpath)
1475 {
1476 case RENDERPATH_GL32:
1477 case RENDERPATH_GLES2:
1483 break;
1484 }
1485}
cvar_t v_glslgamma_2d
Definition vid_shared.c:187
@ SHADERMODE_GENERIC
(particles/HUD/etc) vertex color, optionally multiplied by one texture
Definition render.h:52
#define SHADERPERMUTATION_REFLECTCUBE
fake reflections using global cubemap (not HDRI light probe)
Definition render.h:96
qbool sRGB2D
Definition vid.h:82

Referenced by R_Bloom_MakeTexture(), R_DrawExplosion_TransparentCallback(), R_DrawModelDecals_Entity(), R_DrawParticle_TransparentCallback(), R_MotionBlurView(), R_SetupShader_Generic_NoTexture(), and SCR_DrawLoadingScreen().

◆ R_SetupShader_Generic_NoTexture()

◆ R_SetupShader_SetPermutationGLSL()

static void R_SetupShader_SetPermutationGLSL ( unsigned int  mode,
uint64_t  permutation 
)
static

Definition at line 1346 of file gl_rmain.c.

1347{
1349 if (r_glsl_permutation != perm)
1350 {
1353 {
1355 {
1356 Con_DPrintf("Compiling shader mode %u permutation %" PRIx64 "\n", mode, permutation);
1357 R_GLSL_CompilePermutation(perm, mode, permutation);
1358 }
1360 {
1361 // remove features until we find a valid permutation
1362 unsigned i;
1363 for (i = 0;i < SHADERPERMUTATION_COUNT;i++)
1364 {
1365 // reduce i more quickly whenever it would not remove any bits
1367 if (!(permutation & j))
1368 continue;
1369 permutation -= j;
1372 R_GLSL_CompilePermutation(perm, mode, permutation);
1374 break;
1375 }
1377 {
1378 //Con_Printf("Could not find a working OpenGL 2.0 shader for permutation %s %s\n", shadermodeinfo[mode].filename, shadermodeinfo[mode].pretext);
1381 return; // no bit left to clear, entire mode is broken
1382 }
1383 }
1384 }
1387 }
1392}
static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:1024
static r_glsl_permutation_t * R_GLSL_FindPermutation(unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:940

Referenced by gl_main_start(), R_BlendView(), R_SetupShader_DeferredLight(), R_SetupShader_DepthOrShadow(), R_SetupShader_Generic(), and R_SetupShader_Surface().

◆ R_SetupShader_Surface()

void R_SetupShader_Surface ( const float  rtlightambient[3],
const float  rtlightdiffuse[3],
const float  rtlightspecular[3],
rsurfacepass_t  rsurfacepass,
int  texturenumsurfaces,
const msurface_t **  texturesurfacelist,
void surfacewaterplane,
qbool  notrippy,
qbool  ui 
)

Definition at line 1562 of file gl_rmain.c.

1563{
1564 // select a permutation of the lighting shader appropriate to this
1565 // combination of texture, entity, light source, and fogging, only use the
1566 // minimum features necessary to avoid wasting rendering time in the
1567 // fragment shader on features that are not being used
1568 uint64_t permutation = 0;
1569 unsigned int mode = 0;
1570 int blendfuncflags;
1572 float m16f[16];
1575 if (r_trippy.integer && !notrippy)
1576 permutation |= SHADERPERMUTATION_TRIPPY;
1578 permutation |= SHADERPERMUTATION_ALPHAKILL;
1580 permutation |= SHADERPERMUTATION_OCCLUDE;
1581 if (t->r_water_waterscroll[0] && t->r_water_waterscroll[1])
1582 permutation |= SHADERPERMUTATION_NORMALMAPSCROLLBLEND; // todo: make generic
1584 {
1585 // distorted background
1587 {
1590 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1592 {
1593 // this is the right thing to do for wateralpha
1596 }
1597 else
1598 {
1599 // this is the right thing to do for entity alpha
1602 }
1603 }
1605 {
1608 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1611 }
1612 else
1613 {
1618 }
1620 GL_AlphaToCoverage(false);
1621 }
1623 {
1625 {
1626 switch(t->offsetmapping)
1627 {
1628 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1631 case OFFSETMAPPING_OFF: break;
1632 }
1633 }
1636 // normalmap (deferred prepass), may use alpha test on diffuse
1641 GL_AlphaToCoverage(false);
1642 }
1643 else if (rsurfacepass == RSURFPASS_RTLIGHT)
1644 {
1646 {
1647 switch(t->offsetmapping)
1648 {
1649 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1652 case OFFSETMAPPING_OFF: break;
1653 }
1654 }
1658 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1659 // light source
1662 permutation |= SHADERPERMUTATION_CUBEFILTER;
1664 permutation |= SHADERPERMUTATION_DIFFUSE;
1667 if (r_refdef.fogenabled)
1669 if (t->colormapping)
1670 permutation |= SHADERPERMUTATION_COLORMAPPING;
1672 {
1673 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1675 permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT;
1676
1678 permutation |= SHADERPERMUTATION_DEPTHRGB;
1679 }
1680 if (t->reflectmasktexture)
1681 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1685 GL_AlphaToCoverage(false);
1686 }
1688 {
1690 {
1691 switch(t->offsetmapping)
1692 {
1693 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1696 case OFFSETMAPPING_OFF: break;
1697 }
1698 }
1702 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1703 // directional model lighting
1706 permutation |= SHADERPERMUTATION_GLOW;
1707 permutation |= SHADERPERMUTATION_DIFFUSE;
1709 permutation |= SHADERPERMUTATION_SPECULAR;
1710 if (r_refdef.fogenabled)
1712 if (t->colormapping)
1713 permutation |= SHADERPERMUTATION_COLORMAPPING;
1715 {
1716 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1717 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1718
1720 permutation |= SHADERPERMUTATION_DEPTHRGB;
1721 }
1723 permutation |= SHADERPERMUTATION_REFLECTION;
1726 if (t->reflectmasktexture)
1727 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1729 {
1730 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1733 }
1736 // when using alphatocoverage, we don't need alphakill
1738 {
1740 {
1742 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1743 }
1744 else
1745 GL_AlphaToCoverage(false);
1746 }
1747 }
1749 {
1751 {
1752 switch(t->offsetmapping)
1753 {
1754 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1757 case OFFSETMAPPING_OFF: break;
1758 }
1759 }
1763 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1764 // directional model lighting
1767 permutation |= SHADERPERMUTATION_GLOW;
1769 permutation |= SHADERPERMUTATION_DIFFUSE;
1771 permutation |= SHADERPERMUTATION_SPECULAR;
1772 if (r_refdef.fogenabled)
1774 if (t->colormapping)
1775 permutation |= SHADERPERMUTATION_COLORMAPPING;
1777 {
1778 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1779 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1780
1782 permutation |= SHADERPERMUTATION_DEPTHRGB;
1783 }
1785 permutation |= SHADERPERMUTATION_REFLECTION;
1788 if (t->reflectmasktexture)
1789 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1791 {
1792 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1795 }
1798 // when using alphatocoverage, we don't need alphakill
1800 {
1802 {
1804 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1805 }
1806 else
1807 GL_AlphaToCoverage(false);
1808 }
1809 }
1810 else
1811 {
1813 {
1814 switch(t->offsetmapping)
1815 {
1816 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1819 case OFFSETMAPPING_OFF: break;
1820 }
1821 }
1825 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1826 // lightmapped wall
1828 permutation |= SHADERPERMUTATION_GLOW;
1829 if (r_refdef.fogenabled && !ui)
1831 if (t->colormapping)
1832 permutation |= SHADERPERMUTATION_COLORMAPPING;
1834 {
1835 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1836 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1837
1839 permutation |= SHADERPERMUTATION_DEPTHRGB;
1840 }
1842 permutation |= SHADERPERMUTATION_REFLECTION;
1845 if (t->reflectmasktexture)
1846 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1848 {
1849 // deluxemapping (light direction texture)
1852 else
1854 permutation |= SHADERPERMUTATION_DIFFUSE;
1857 }
1858 else if (r_glsl_deluxemapping.integer >= 2)
1859 {
1860 // fake deluxemapping (uniform light direction in tangentspace)
1863 else
1865 permutation |= SHADERPERMUTATION_DIFFUSE;
1868 }
1870 {
1871 // ordinary lightmapping (q1bsp, q3bsp)
1873 }
1874 else
1875 {
1876 // ordinary vertex coloring (q3bsp)
1878 }
1880 {
1881 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1884 }
1887 // when using alphatocoverage, we don't need alphakill
1889 {
1891 {
1893 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1894 }
1895 else
1896 GL_AlphaToCoverage(false);
1897 }
1898 }
1902 permutation |= SHADERPERMUTATION_FOGALPHAHACK;
1903 switch(vid.renderpath)
1904 {
1905 case RENDERPATH_GL32:
1906 case RENDERPATH_GLES2:
1909 // this has to be after RSurf_PrepareVerticesForBatch
1911 permutation |= SHADERPERMUTATION_SKELETAL;
1913#ifndef USE_GLES2 /* FIXME: GLES3 only */
1915#endif
1918 {
1922 if (r_glsl_permutation->loc_Color_Ambient >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Ambient, rtlightambient[0], rtlightambient[1], rtlightambient[2]);
1925
1926 // additive passes are only darkened by fog, not tinted
1930 }
1931 else
1932 {
1934 {
1936 }
1937 else if (mode == SHADERMODE_LIGHTGRID)
1938 {
1942 // other LightGrid uniforms handled below
1943 }
1944 else if (mode == SHADERMODE_LIGHTDIRECTION)
1945 {
1953 }
1954 else
1955 {
1961 }
1962 // additive passes are only darkened by fog, not tinted
1963 if (r_glsl_permutation->loc_FogColor >= 0 && !ui)
1964 {
1967 else
1969 }
1979 }
1983 if (permutation & SHADERPERMUTATION_SHADOWMAPORTHO)
1984 {
1987 }
1988 else
1989 {
1992 }
1993
1998 {
1999 if (t->pantstexture)
2001 else
2003 }
2005 {
2006 if (t->shirttexture)
2008 else
2010 }
2020 );
2028 {
2029 float m9f[9];
2035 m9f[0] = m16f[0];m9f[1] = m16f[1];m9f[2] = m16f[2];
2036 m9f[3] = m16f[4];m9f[4] = m16f[5];m9f[5] = m16f[6];
2037 m9f[6] = m16f[8];m9f[7] = m16f[9];m9f[8] = m16f[10];
2039 }
2040
2062 {
2066 }
2067 else
2068 {
2070 }
2075 {
2077 if (rsurface.rtlight)
2078 {
2081 }
2082 }
2086 break;
2087 }
2088}
rtexture_t * r_shadow_prepasslightingdiffusetexture
Definition r_shadow.c:121
rtexture_t * r_shadow_prepasslightingspeculartexture
Definition r_shadow.c:122
void RSurf_UploadBuffersForBatch(void)
Definition gl_rmain.c:7376
#define BLENDFUNC_ALLOWS_ANYFOG
Definition gl_rmain.c:1520
int R_TextureFlags(rtexture_t *rt)
void Matrix4x4_Normalize3(matrix4x4_t *out, matrix4x4_t *in1)
Definition matrixlib.c:508
#define MATERIALFLAG_OCCLUDE
#define RENDER_NOSELFSHADOW
Definition protocol.h:368
@ OFFSETMAPPING_DEFAULT
Definition r_qshader.h:186
@ OFFSETMAPPING_LINEAR
Definition r_qshader.h:187
@ OFFSETMAPPING_RELIEF
Definition r_qshader.h:188
float r_shadow_modelshadowmap_parameters[4]
Definition r_shadow.c:43
qbool r_shadow_usingshadowmaportho
Definition r_shadow.c:38
matrix4x4_t r_shadow_shadowmapmatrix
Definition r_shadow.c:62
r_shadow_bouncegrid_state_t r_shadow_bouncegrid_state
Definition r_shadow.c:259
float r_shadow_modelshadowmap_texturescale[4]
Definition r_shadow.c:42
#define SHADERPERMUTATION_FOGALPHAHACK
fog color and density determined by texture mapped on vertical axis
Definition render.h:81
@ SHADERMODE_DEFERREDGEOMETRY
(deferred) render material properties to screenspace geometry buffers
Definition render.h:67
@ SHADERMODE_FLATCOLOR
(lightmap) modulate texture by uniform color (q1bsp, q3bsp)
Definition render.h:55
@ SHADERMODE_LIGHTDIRECTION
(lightmap) use directional pixel shading from fixed light direction (q3bsp)
Definition render.h:63
@ SHADERMODE_VERTEXCOLOR
(lightmap) modulate texture by vertex colors (q3bsp)
Definition render.h:56
@ SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE
(lightmap) use directional pixel shading from texture containing modelspace light directions (q3bsp d...
Definition render.h:58
@ SHADERMODE_LIGHTMAP
(lightmap) modulate texture by lightmap texture (q1bsp, q3bsp)
Definition render.h:57
@ SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP
Definition render.h:60
@ SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE
(lightmap) use directional pixel shading from texture containing tangentspace light directions (q1bsp...
Definition render.h:59
@ SHADERMODE_WATER
refract background and reflection (the material is rendered normally after this pass)
Definition render.h:66
@ SHADERMODE_LIGHTSOURCE
(lightsource) use directional pixel shading from light source (rtlight)
Definition render.h:64
@ SHADERMODE_LIGHTGRID
(lightmap) use directional pixel shading from lightgrid data (q3bsp)
Definition render.h:62
@ SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR
Definition render.h:61
@ SHADERMODE_REFRACTION
refract background (the material is rendered normally after this pass)
Definition render.h:65
#define SHADERPERMUTATION_ALPHAKILL
(deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha
Definition render.h:95
#define SHADERPERMUTATION_ALPHAGEN_VERTEX
alphaGen vertex
Definition render.h:102
#define SHADERPERMUTATION_GLOW
(lightmap) blend in an additive glow texture
Definition render.h:84
#define SHADERPERMUTATION_FOGHEIGHTTEXTURE
fog color and density determined by texture mapped on vertical axis
Definition render.h:80
#define SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL
(lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standar...
Definition render.h:99
#define SHADERPERMUTATION_FOGOUTSIDE
tint the color by fog color or black if using additive blend mode
Definition render.h:79
#define SHADERPERMUTATION_OCCLUDE
use occlusion buffer for corona
Definition render.h:104
#define BATCHNEED_ARRAY_LIGHTMAP
Definition render.h:796
#define SHADERPERMUTATION_OFFSETMAPPING
adjust texcoords to roughly simulate a displacement mapped surface
Definition render.h:89
#define SHADERPERMUTATION_BOUNCEGRID
(lightmap) use Texture_BounceGrid as an additional source of ambient light
Definition render.h:98
#define SHADERPERMUTATION_VERTEXTEXTUREBLEND
indicates this is a two-layer material blend based on vertex alpha (q3bsp)
Definition render.h:74
#define SHADERPERMUTATION_FOGINSIDE
tint the color by fog color or black if using additive blend mode
Definition render.h:78
#define SHADERPERMUTATION_NORMALMAPSCROLLBLEND
(water) counter-direction normalmaps scrolling
Definition render.h:97
#define SHADERPERMUTATION_SHADOWMAPORTHO
(lightsource) use orthographic shadowmap projection
Definition render.h:93
#define SHADERPERMUTATION_REFLECTION
normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the su...
Definition render.h:88
@ RSURFPASS_RTLIGHT
Definition render.h:811
#define SHADERPERMUTATION_DEFERREDLIGHTMAP
(lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping
Definition render.h:94
#define SHADERPERMUTATION_COLORMAPPING
indicates this is a colormapped skin
Definition render.h:76
#define BATCHNEED_ARRAY_TEXCOORD
Definition render.h:795
#define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING
adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also...
Definition render.h:90
matrix4x4_t lightgridworldtotexturematrix
qbool deluxemapping_modelspace
rtexture_t * lightgridtexture
model_brushq3_t brushq3
qbool fogplaneviewabove
Definition render.h:427
float quality
render quality (0 to 1) - affects r_drawparticles_drawdistance and others
Definition render.h:321
struct rtexture_s * texture
Definition r_shadow.h:100
float screencenter[2]
Definition render.h:877
float screenscale[2]
Definition render.h:876
matrix4x4_t entitytolight
Definition render.h:759
float fogplaneviewdist
Definition render.h:749
float fogheightfade
Definition render.h:748
float fograngerecip
Definition render.h:745
vec3_t entitylightorigin
Definition render.h:756
float fogplane[4]
Definition render.h:747
float refractfactor
dpoffsetmapping_technique_t offsetmapping
float r_water_waterscroll[2]
float reflectmin
vec4_t refractcolor4f
struct rtexture_s * reflectcubetexture
float reflectmax
float offsetscale
float r_water_wateralpha
float reflectfactor
float offsetbias
vec4_t reflectcolor4f

Referenced by R_DrawTextureSurfaceList_GL20(), and R_Shadow_RenderLighting_Light_GLSL().

◆ R_SetupView()

void R_SetupView ( qbool  allowwaterclippingplane,
int  viewfbo,
rtexture_t viewdepthtexture,
rtexture_t viewcolortexture,
int  viewx,
int  viewy,
int  viewwidth,
int  viewheight 
)

Definition at line 4392 of file gl_rmain.c.

4393{
4394 const float *customclipplane = NULL;
4395 float plane[4];
4396 int viewy_adjusted;
4398 {
4399 // LadyHavoc: couldn't figure out how to make this approach work the same in DPSOFTRAST
4403 dist = r_refdef.view.clipplane.dist;
4404 plane[0] = r_refdef.view.clipplane.normal[0];
4405 plane[1] = r_refdef.view.clipplane.normal[1];
4406 plane[2] = r_refdef.view.clipplane.normal[2];
4407 plane[3] = -dist;
4408 customclipplane = plane;
4409 }
4410
4411 // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom.
4412 // Unless the render target is a FBO...
4414
4419 else
4423}
void R_Viewport_InitPerspective(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:676
void R_Viewport_InitOrtho3D(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:634
void R_Viewport_InitPerspectiveInfinite(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, const float *nearplane)
Definition gl_backend.c:718
double farclip
Definition render.h:418
double nearclip
Definition render.h:415
float frustum_y
Definition render.h:277
qbool useclipplane
Definition render.h:274
float frustum_x
Definition render.h:277
float ortho_x
Definition render.h:287
float ortho_y
Definition render.h:287
mplane_t clipplane
Definition render.h:276
qbool stencil
Definition vid.h:81

Referenced by R_RenderScene(), R_ResetViewRendering3D(), and R_Water_ProcessPlanes().

◆ R_ShaderStrCat()

static char * R_ShaderStrCat ( const char **  strings)
static

Definition at line 965 of file gl_rmain.c.

966{
967 char *string, *s;
968 const char **p = strings;
969 const char *t;
970 size_t len = 0;
971 for (p = strings;(t = *p);p++)
972 len += strlen(t);
973 len++;
974 s = string = (char *)Mem_Alloc(r_main_mempool, len);
975 len = 0;
976 for (p = strings;(t = *p);p++)
977 {
978 len = strlen(t);
979 memcpy(s, t, len);
980 s += len;
981 }
982 *s = 0;
983 return string;
984}
GLsizei const GLchar ** string
Definition glquake.h:727

Referenced by R_InitShaderModeInfo().

◆ R_SkinFrame_Find()

skinframe_t * R_SkinFrame_Find ( const char name,
int  textureflags,
int  comparewidth,
int  compareheight,
int  comparecrc,
qbool  add 
)

Definition at line 2239 of file gl_rmain.c.

2240{
2242 int compareflags = textureflags & TEXF_IMPORTANTBITS;
2243 int hashindex;
2244 char basename[MAX_QPATH];
2245
2246 Image_StripImageExtension(name, basename, sizeof(basename));
2247
2248 hashindex = CRC_Block((unsigned char *)basename, strlen(basename)) & (SKINFRAME_HASH - 1);
2249 for (item = r_skinframe.hash[hashindex];item;item = item->next)
2250 if (!strcmp(item->basename, basename) &&
2251 item->textureflags == compareflags &&
2252 item->comparewidth == comparewidth &&
2253 item->compareheight == compareheight &&
2254 item->comparecrc == comparecrc)
2255 break;
2256
2257 if (!item)
2258 {
2259 if (!add)
2260 return NULL;
2262 memset(item, 0, sizeof(*item));
2263 dp_strlcpy(item->basename, basename, sizeof(item->basename));
2264 item->textureflags = compareflags;
2265 item->comparewidth = comparewidth;
2266 item->compareheight = compareheight;
2267 item->comparecrc = comparecrc;
2268 item->next = r_skinframe.hash[hashindex];
2270 }
2271 else if (textureflags & TEXF_FORCE_RELOAD)
2273
2275 return item;
2276}
#define SKINFRAME_HASH
Definition gl_rmain.c:2156
void R_SkinFrame_PurgeSkinFrame(skinframe_t *s)
Definition gl_rmain.c:2183
void R_SkinFrame_MarkUsed(skinframe_t *skinframe)
Definition gl_rmain.c:2175
void Image_StripImageExtension(const char *in, char *out, size_t size_out)
Definition image.c:913
#define TEXF_IMPORTANTBITS
Definition r_textures.h:39
#define TEXF_FORCE_RELOAD
Definition r_textures.h:41
skinframe_t * hash[SKINFRAME_HASH]
Definition gl_rmain.c:2162

Referenced by R_LoadQWSkin(), R_SkinFrame_LoadExternal(), R_SkinFrame_LoadExternal_SkinFrame(), R_SkinFrame_LoadInternal8bit(), R_SkinFrame_LoadInternalBGRA(), R_SkinFrame_LoadInternalQuake(), R_SkinFrame_LoadInternalUsingTexture(), and R_SkinFrame_LoadMissing().

◆ R_SkinFrame_FindNextByName()

skinframe_t * R_SkinFrame_FindNextByName ( skinframe_t last,
const char name 
)

Definition at line 2216 of file gl_rmain.c.

2216 {
2218 char basename[MAX_QPATH];
2219
2220 Image_StripImageExtension(name, basename, sizeof(basename));
2221
2222 if( last == NULL ) {
2223 int hashindex;
2224 hashindex = CRC_Block((unsigned char *)basename, strlen(basename)) & (SKINFRAME_HASH - 1);
2226 } else {
2227 item = last->next;
2228 }
2229
2230 // linearly search through the hash bucket
2231 for( ; item ; item = item->next ) {
2232 if( !strcmp( item->basename, basename ) ) {
2233 return item;
2234 }
2235 }
2236 return NULL;
2237}
struct skinframe_s * next
Definition r_textures.h:142

◆ R_SkinFrame_GenerateTexturesFromQPixels()

static void R_SkinFrame_GenerateTexturesFromQPixels ( skinframe_t skinframe,
qbool  colormapped 
)
static

Definition at line 2675 of file gl_rmain.c.

2676{
2677 int width;
2678 int height;
2679 unsigned char *skindata;
2680 char vabuf[1024];
2681
2682 if (!skinframe->qpixels)
2683 return;
2684
2685 if (!skinframe->qhascolormapping)
2686 colormapped = false;
2687
2688 if (colormapped)
2689 {
2690 if (!skinframe->qgeneratebase)
2691 return;
2692 }
2693 else
2694 {
2695 if (!skinframe->qgeneratemerged)
2696 return;
2697 }
2698
2699 width = skinframe->qwidth;
2700 height = skinframe->qheight;
2701 skindata = skinframe->qpixels;
2702
2703 if (skinframe->qgeneratenmap)
2704 {
2705 unsigned char *a, *b;
2706 skinframe->qgeneratenmap = false;
2707 a = (unsigned char *)Mem_Alloc(tempmempool, width * height * 8);
2708 b = a + width * height * 4;
2709 // use either a custom palette or the quake palette
2712 skinframe->nmap = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), width, height, b, TEXTYPE_BGRA, (skinframe->textureflags | TEXF_ALPHA) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP), -1, NULL);
2713 Mem_Free(a);
2714 }
2715
2716 if (skinframe->qgenerateglow)
2717 {
2718 skinframe->qgenerateglow = false;
2719 if (skinframe->hasalpha) // fence textures
2720 skinframe->glow = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags | TEXF_ALPHA, -1, palette_bgra_onlyfullbrights_transparent); // glow
2721 else
2722 skinframe->glow = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, palette_bgra_onlyfullbrights); // glow
2723 }
2724
2725 if (colormapped)
2726 {
2727 skinframe->qgeneratebase = false;
2728 skinframe->base = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nospecial", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, skinframe->glow ? palette_bgra_nocolormapnofullbrights : palette_bgra_nocolormap);
2729 skinframe->pants = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_pants", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, palette_bgra_pantsaswhite);
2730 skinframe->shirt = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_shirt", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, palette_bgra_shirtaswhite);
2731 }
2732 else
2733 {
2734 skinframe->qgeneratemerged = false;
2735 if (skinframe->hasalpha) // fence textures
2737 else
2739 }
2740
2741 if (!skinframe->qgeneratemerged && !skinframe->qgeneratebase)
2742 {
2743 Mem_Free(skinframe->qpixels);
2744 skinframe->qpixels = NULL;
2745 }
2746}
void Image_HeightmapToNormalmap_BGRA(const unsigned char *inpixels, unsigned char *outpixels, int width, int height, int clamp, float bumpscale)
Definition image.c:1769
void Image_Copy8bitBGRA(const unsigned char *in, unsigned char *out, int pixels, const unsigned int *pal)
Definition image.c:129
cvar_t r_mipnormalmaps
unsigned int palette_bgra_nocolormap[256]
Definition palette.c:16
unsigned int palette_bgra_transparent[256]
Definition palette.c:24
unsigned int palette_bgra_onlyfullbrights_transparent[256]
Definition palette.c:21
unsigned int palette_bgra_nocolormapnofullbrights[256]
Definition palette.c:17
unsigned int palette_bgra_shirtaswhite[256]
Definition palette.c:23
unsigned int palette_bgra_complete[256]
Definition palette.c:13
unsigned int palette_bgra_nofullbrights_transparent[256]
Definition palette.c:19
unsigned int palette_bgra_nofullbrights[256]
Definition palette.c:18
unsigned int palette_bgra_onlyfullbrights[256]
Definition palette.c:20
unsigned int palette_bgra_pantsaswhite[256]
Definition palette.c:22
cvar_t r_shadow_bumpscale_basetexture
Definition r_shadow.c:141
@ TEXTYPE_PALETTE
Definition r_textures.h:49
@ TEXTYPE_SRGB_PALETTE
Definition r_textures.h:69
struct rtexture_s * pants
Definition r_textures.h:130
qbool qgeneratebase
Definition r_textures.h:161
struct rtexture_s * merged
Definition r_textures.h:128
struct rtexture_s * shirt
Definition r_textures.h:131
qbool qhascolormapping
Definition r_textures.h:160
struct rtexture_s * nmap
Definition r_textures.h:132
qbool qgenerateglow
Definition r_textures.h:164
unsigned char * qpixels
Definition r_textures.h:157
struct rtexture_s * glow
Definition r_textures.h:134
qbool qgeneratenmap
Definition r_textures.h:163
char basename[MAX_QPATH]
Definition r_textures.h:143
qbool qgeneratemerged
Definition r_textures.h:162
qbool hasalpha
Definition r_textures.h:153

Referenced by R_GetCurrentTexture().

◆ R_SkinFrame_LoadExternal()

skinframe_t * R_SkinFrame_LoadExternal ( const char name,
int  textureflags,
qbool  complain,
qbool  fallbacknotexture 
)

Definition at line 2313 of file gl_rmain.c.

2314{
2315 skinframe_t *skinframe;
2316
2317 if (cls.state == ca_dedicated)
2318 return NULL;
2319
2320 // return an existing skinframe if already loaded
2321 skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, false);
2322 if (skinframe && skinframe->base)
2323 return skinframe;
2324
2325 // if the skinframe doesn't exist this will create it
2326 return R_SkinFrame_LoadExternal_SkinFrame(skinframe, name, textureflags, complain, fallbacknotexture);
2327}
@ ca_dedicated
Definition client.h:531
skinframe_t * R_SkinFrame_LoadExternal_SkinFrame(skinframe_t *skinframe, const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
Definition gl_rmain.c:2330
cactive_t state
Definition client.h:569

Referenced by Draw_CachePic_Flags(), Draw_GetPicTexture(), Draw_IsPicLoaded(), Mod_CreateShaderPassFromQ3ShaderLayer(), Mod_IDP0_Load(), Mod_IDS2_Load(), Mod_LoadTextureFromQ3Shader(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), R_InitParticleTexture(), and R_ReplaceWorldTexture_f().

◆ R_SkinFrame_LoadExternal_SkinFrame()

skinframe_t * R_SkinFrame_LoadExternal_SkinFrame ( skinframe_t skinframe,
const char name,
int  textureflags,
qbool  complain,
qbool  fallbacknotexture 
)

Definition at line 2330 of file gl_rmain.c.

2331{
2332 int j;
2333 unsigned char *pixels;
2334 unsigned char *bumppixels;
2335 unsigned char *basepixels = NULL;
2336 int basepixels_width = 0;
2337 int basepixels_height = 0;
2339 qbool ddshasalpha = false;
2340 float ddsavgcolor[4];
2341 char basename[MAX_QPATH];
2342 int miplevel = R_PicmipForFlags(textureflags);
2343 int savemiplevel = miplevel;
2344 int mymiplevel;
2345 char vabuf[1024];
2346
2347 if (cls.state == ca_dedicated)
2348 return NULL;
2349
2350 Image_StripImageExtension(name, basename, sizeof(basename));
2351
2352 // check for DDS texture file first
2353 if (!r_loaddds || !(ddsbase = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s.dds", basename), vid.sRGB3D, textureflags, &ddshasalpha, ddsavgcolor, miplevel, false)))
2354 {
2355 basepixels = loadimagepixelsbgra(name, complain, true, false, &miplevel);
2358 if (basepixels == NULL)
2359 return NULL;
2360 }
2361
2362 // FIXME handle miplevel
2363
2365 Con_Printf("loading skin \"%s\"\n", name);
2366
2367 // we've got some pixels to store, so really allocate this new texture now
2368 if (!skinframe)
2369 skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, true);
2370 textureflags &= ~TEXF_FORCE_RELOAD;
2371 skinframe->stain = NULL;
2372 skinframe->merged = NULL;
2373 skinframe->base = NULL;
2374 skinframe->pants = NULL;
2375 skinframe->shirt = NULL;
2376 skinframe->nmap = NULL;
2377 skinframe->gloss = NULL;
2378 skinframe->glow = NULL;
2379 skinframe->fog = NULL;
2380 skinframe->reflect = NULL;
2381 skinframe->hasalpha = false;
2382 // we could store the q2animname here too
2383
2384 if (ddsbase)
2385 {
2386 skinframe->base = ddsbase;
2387 skinframe->hasalpha = ddshasalpha;
2388 VectorCopy(ddsavgcolor, skinframe->avgcolor);
2389 if (r_loadfog && skinframe->hasalpha)
2390 skinframe->fog = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_mask.dds", skinframe->basename), false, textureflags | TEXF_ALPHA, NULL, NULL, miplevel, true);
2391 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2392 }
2393 else
2394 {
2398 if (textureflags & TEXF_ALPHA)
2399 {
2400 for (j = 3;j < basepixels_width * basepixels_height * 4;j += 4)
2401 {
2402 if (basepixels[j] < 255)
2403 {
2404 skinframe->hasalpha = true;
2405 break;
2406 }
2407 }
2408 if (r_loadfog && skinframe->hasalpha)
2409 {
2410 // has transparent pixels
2411 pixels = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
2412 for (j = 0;j < image_width * image_height * 4;j += 4)
2413 {
2414 pixels[j+0] = 255;
2415 pixels[j+1] = 255;
2416 pixels[j+2] = 255;
2417 pixels[j+3] = basepixels[j+3];
2418 }
2421 }
2422 }
2424#ifndef USE_GLES2
2425 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2426 if (r_savedds && skinframe->base)
2427 R_SaveTextureDDSFile(skinframe->base, va(vabuf, sizeof(vabuf), "dds/%s.dds", skinframe->basename), r_texture_dds_save.integer < 2, skinframe->hasalpha);
2428 if (r_savedds && skinframe->fog)
2429 R_SaveTextureDDSFile(skinframe->fog, va(vabuf, sizeof(vabuf), "dds/%s_mask.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2430#endif
2431 }
2432
2433 if (r_loaddds)
2434 {
2436 if (r_loadnormalmap)
2437 skinframe->nmap = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_norm.dds", skinframe->basename), false, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP), NULL, NULL, mymiplevel, true);
2438 skinframe->glow = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_glow.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2439 if (r_loadgloss)
2440 skinframe->gloss = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_gloss.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2441 skinframe->pants = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_pants.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2442 skinframe->shirt = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_shirt.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2443 skinframe->reflect = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_reflect.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2444 }
2445
2446 // _norm is the name used by tenebrae and has been adopted as standard
2447 if (r_loadnormalmap && skinframe->nmap == NULL)
2448 {
2450 if ((pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_norm", skinframe->basename), false, false, false, &mymiplevel)) != NULL)
2451 {
2454 pixels = NULL;
2455 }
2456 else if (r_shadow_bumpscale_bumpmap.value > 0 && (bumppixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_bump", skinframe->basename), false, false, false, &mymiplevel)) != NULL)
2457 {
2458 pixels = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
2463 }
2465 {
2470 }
2471#ifndef USE_GLES2
2472 if (r_savedds && skinframe->nmap)
2473 R_SaveTextureDDSFile(skinframe->nmap, va(vabuf, sizeof(vabuf), "dds/%s_norm.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2474#endif
2475 }
2476
2477 // _luma is supported only for tenebrae compatibility
2478 // _blend and .blend are supported only for Q3 & QL compatibility, this hack can be removed if better Q3 shader support is implemented
2479 // _glow is the preferred name
2481 if (skinframe->glow == NULL && ((pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s.blend", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_blend", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_luma", skinframe->basename), false, false, false, &mymiplevel))))
2482 {
2484#ifndef USE_GLES2
2485 if (r_savedds && skinframe->glow)
2486 R_SaveTextureDDSFile(skinframe->glow, va(vabuf, sizeof(vabuf), "dds/%s_glow.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2487#endif
2489 }
2490
2492 if (skinframe->gloss == NULL && r_loadgloss && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_gloss", skinframe->basename), false, false, false, &mymiplevel)))
2493 {
2495#ifndef USE_GLES2
2496 if (r_savedds && skinframe->gloss)
2497 R_SaveTextureDDSFile(skinframe->gloss, va(vabuf, sizeof(vabuf), "dds/%s_gloss.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2498#endif
2500 pixels = NULL;
2501 }
2502
2504 if (skinframe->pants == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_pants", skinframe->basename), false, false, false, &mymiplevel)))
2505 {
2507#ifndef USE_GLES2
2508 if (r_savedds && skinframe->pants)
2509 R_SaveTextureDDSFile(skinframe->pants, va(vabuf, sizeof(vabuf), "dds/%s_pants.dds", skinframe->basename), r_texture_dds_save.integer < 2, false);
2510#endif
2512 pixels = NULL;
2513 }
2514
2516 if (skinframe->shirt == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_shirt", skinframe->basename), false, false, false, &mymiplevel)))
2517 {
2519#ifndef USE_GLES2
2520 if (r_savedds && skinframe->shirt)
2521 R_SaveTextureDDSFile(skinframe->shirt, va(vabuf, sizeof(vabuf), "dds/%s_shirt.dds", skinframe->basename), r_texture_dds_save.integer < 2, false);
2522#endif
2524 pixels = NULL;
2525 }
2526
2528 if (skinframe->reflect == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_reflect", skinframe->basename), false, false, false, &mymiplevel)))
2529 {
2531#ifndef USE_GLES2
2532 if (r_savedds && skinframe->reflect)
2533 R_SaveTextureDDSFile(skinframe->reflect, va(vabuf, sizeof(vabuf), "dds/%s_reflect.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2534#endif
2536 pixels = NULL;
2537 }
2538
2539 if (basepixels)
2541
2542 return skinframe;
2543}
#define R_SKINFRAME_LOAD_AVERAGE_COLORS(cnt, getpixel)
Definition gl_rmain.c:2278
cvar_t gl_texturecompression_reflectmask
Definition gl_textures.c:47
cvar_t gl_texturecompression_color
Definition gl_textures.c:38
rtexture_t * R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filename, qbool srgb, int flags, qbool *hasalphaflag, float *avgcolor, int miplevel, qbool optionaltexture)
int R_SaveTextureDDSFile(rtexture_t *rt, const char *filename, qbool skipuncompressed, qbool hasalpha)
cvar_t gl_texturecompression_glow
Definition gl_textures.c:41
cvar_t gl_texturecompression_gloss
Definition gl_textures.c:40
int R_PicmipForFlags(int flags)
cvar_t gl_texturecompression_normal
Definition gl_textures.c:39
cvar_t r_shadow_bumpscale_bumpmap
Definition r_shadow.c:142
struct rtexture_s * stain
Definition r_textures.h:127
struct rtexture_s * reflect
Definition r_textures.h:136
struct rtexture_s * gloss
Definition r_textures.h:133
struct rtexture_s * fog
Definition r_textures.h:135
float avgcolor[4]
Definition r_textures.h:155

Referenced by Draw_CachePic_Flags(), and R_SkinFrame_LoadExternal().

◆ R_SkinFrame_LoadInternal8bit()

skinframe_t * R_SkinFrame_LoadInternal8bit ( const char name,
int  textureflags,
const unsigned char skindata,
int  width,
int  height,
const unsigned int palette,
const unsigned int alphapalette 
)

Definition at line 2748 of file gl_rmain.c.

2749{
2750 int i;
2751 skinframe_t *skinframe;
2752 char vabuf[1024];
2753
2754 if (cls.state == ca_dedicated)
2755 return NULL;
2756
2757 // if already loaded just return it, otherwise make a new skinframe
2758 skinframe = R_SkinFrame_Find(name, textureflags, width, height, skindata ? CRC_Block(skindata, width*height) : 0, true);
2759 if (skinframe->base)
2760 return skinframe;
2761 textureflags &= ~TEXF_FORCE_RELOAD;
2762
2763 skinframe->stain = NULL;
2764 skinframe->merged = NULL;
2765 skinframe->base = NULL;
2766 skinframe->pants = NULL;
2767 skinframe->shirt = NULL;
2768 skinframe->nmap = NULL;
2769 skinframe->gloss = NULL;
2770 skinframe->glow = NULL;
2771 skinframe->fog = NULL;
2772 skinframe->reflect = NULL;
2773 skinframe->hasalpha = false;
2774
2775 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2776 if (!skindata)
2777 return NULL;
2778
2780 Con_Printf("loading embedded 8bit image \"%s\"\n", name);
2781
2782 skinframe->base = skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, TEXTYPE_PALETTE, textureflags, -1, palette);
2783 if ((textureflags & TEXF_ALPHA) && alphapalette)
2784 {
2785 for (i = 0;i < width * height;i++)
2786 {
2787 if (((unsigned char *)palette)[skindata[i]*4+3] < 255)
2788 {
2789 skinframe->hasalpha = true;
2790 break;
2791 }
2792 }
2793 if (r_loadfog && skinframe->hasalpha)
2794 skinframe->fog = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_fog", skinframe->basename), width, height, skindata, TEXTYPE_PALETTE, textureflags, -1, alphapalette);
2795 }
2796
2797 R_SKINFRAME_LOAD_AVERAGE_COLORS(width * height, ((unsigned char *)palette)[skindata[pix]*4 + comp]);
2798 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2799
2800 return skinframe;
2801}

Referenced by R_Shadow_MakeTextures().

◆ R_SkinFrame_LoadInternalBGRA()

skinframe_t * R_SkinFrame_LoadInternalBGRA ( const char name,
int  textureflags,
const unsigned char skindata,
int  width,
int  height,
int  comparewidth,
int  compareheight,
int  comparecrc,
qbool  sRGB 
)

Definition at line 2545 of file gl_rmain.c.

2546{
2547 int i;
2548 skinframe_t *skinframe;
2549 char vabuf[1024];
2550
2551 if (cls.state == ca_dedicated)
2552 return NULL;
2553
2554 // if already loaded just return it, otherwise make a new skinframe
2555 skinframe = R_SkinFrame_Find(name, textureflags, comparewidth, compareheight, comparecrc, true);
2556 if (skinframe->base)
2557 return skinframe;
2558 textureflags &= ~TEXF_FORCE_RELOAD;
2559
2560 skinframe->stain = NULL;
2561 skinframe->merged = NULL;
2562 skinframe->base = NULL;
2563 skinframe->pants = NULL;
2564 skinframe->shirt = NULL;
2565 skinframe->nmap = NULL;
2566 skinframe->gloss = NULL;
2567 skinframe->glow = NULL;
2568 skinframe->fog = NULL;
2569 skinframe->reflect = NULL;
2570 skinframe->hasalpha = false;
2571
2572 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2573 if (!skindata)
2574 return NULL;
2575
2577 Con_Printf("loading 32bit skin \"%s\"\n", name);
2578
2580 {
2581 unsigned char *a = (unsigned char *)Mem_Alloc(tempmempool, width * height * 8);
2582 unsigned char *b = a + width * height * 4;
2584 skinframe->nmap = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), width, height, b, TEXTYPE_BGRA, (textureflags | TEXF_ALPHA) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP), -1, NULL);
2585 Mem_Free(a);
2586 }
2587 skinframe->base = skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, sRGB ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags, -1, NULL);
2588 if (textureflags & TEXF_ALPHA)
2589 {
2590 for (i = 3;i < width * height * 4;i += 4)
2591 {
2592 if (skindata[i] < 255)
2593 {
2594 skinframe->hasalpha = true;
2595 break;
2596 }
2597 }
2598 if (r_loadfog && skinframe->hasalpha)
2599 {
2600 unsigned char *fogpixels = (unsigned char *)Mem_Alloc(tempmempool, width * height * 4);
2602 for (i = 0;i < width * height * 4;i += 4)
2603 fogpixels[i] = fogpixels[i+1] = fogpixels[i+2] = 255;
2604 skinframe->fog = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_fog", skinframe->basename), width, height, fogpixels, TEXTYPE_BGRA, textureflags, -1, NULL);
2606 }
2607 }
2608
2610 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2611
2612 return skinframe;
2613}

Referenced by CL_Beams_SetupBuiltinTexture(), Curl_EndDownload(), Draw_NewPic(), Mod_Q1BSP_LoadSplitSky(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), R_InitParticleTexture(), R_LoadSkyBox(), R_Shadow_MakeTextures_MakeCorona(), and R_SkinFrame_LoadNoTexture().

◆ R_SkinFrame_LoadInternalQuake()

skinframe_t * R_SkinFrame_LoadInternalQuake ( const char name,
int  textureflags,
int  loadpantsandshirt,
int  loadglowtexture,
const unsigned char skindata,
int  width,
int  height 
)

Definition at line 2615 of file gl_rmain.c.

2616{
2617 int i;
2618 int featuresmask;
2619 skinframe_t *skinframe;
2620
2621 if (cls.state == ca_dedicated)
2622 return NULL;
2623
2624 // if already loaded just return it, otherwise make a new skinframe
2625 skinframe = R_SkinFrame_Find(name, textureflags, width, height, skindata ? CRC_Block(skindata, width*height) : 0, true);
2626 if (skinframe->base)
2627 return skinframe;
2628 //textureflags &= ~TEXF_FORCE_RELOAD;
2629
2630 skinframe->stain = NULL;
2631 skinframe->merged = NULL;
2632 skinframe->base = NULL;
2633 skinframe->pants = NULL;
2634 skinframe->shirt = NULL;
2635 skinframe->nmap = NULL;
2636 skinframe->gloss = NULL;
2637 skinframe->glow = NULL;
2638 skinframe->fog = NULL;
2639 skinframe->reflect = NULL;
2640 skinframe->hasalpha = false;
2641
2642 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2643 if (!skindata)
2644 return NULL;
2645
2647 Con_Printf("loading quake skin \"%s\"\n", name);
2648
2649 // we actually don't upload anything until the first use, because mdl skins frequently go unused, and are almost never used in both modes (colormapped and non-colormapped)
2650 skinframe->qpixels = (unsigned char *)Mem_Alloc(r_main_mempool, width*height); // FIXME LEAK
2651 memcpy(skinframe->qpixels, skindata, width*height);
2652 skinframe->qwidth = width;
2653 skinframe->qheight = height;
2654
2655 featuresmask = 0;
2656 for (i = 0;i < width * height;i++)
2658
2659 skinframe->hasalpha = false;
2660 // fence textures
2661 if (name[0] == '{')
2662 skinframe->hasalpha = true;
2665 skinframe->qgeneratemerged = true;
2666 skinframe->qgeneratebase = skinframe->qhascolormapping;
2668
2670 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2671
2672 return skinframe;
2673}
unsigned char palette_featureflags[256]
Definition palette.c:26
#define PALETTEFEATURE_SHIRT
Definition palette.h:8
#define PALETTEFEATURE_GLOW
Definition palette.h:9
#define PALETTEFEATURE_PANTS
Definition palette.h:7

Referenced by Mod_IDP0_Load(), Mod_Q1BSP_LoadTextures(), and R_LoadQWSkin().

◆ R_SkinFrame_LoadInternalUsingTexture()

skinframe_t * R_SkinFrame_LoadInternalUsingTexture ( const char name,
int  textureflags,
rtexture_t tex,
int  width,
int  height,
qbool  sRGB 
)

Definition at line 2839 of file gl_rmain.c.

2840{
2841 skinframe_t *skinframe;
2842 if (cls.state == ca_dedicated)
2843 return NULL;
2844 // if already loaded just return it, otherwise make a new skinframe
2845 skinframe = R_SkinFrame_Find(name, textureflags, width, height, 0, true);
2846 if (skinframe->base)
2847 return skinframe;
2848 textureflags &= ~TEXF_FORCE_RELOAD;
2849 skinframe->stain = NULL;
2850 skinframe->merged = NULL;
2851 skinframe->base = NULL;
2852 skinframe->pants = NULL;
2853 skinframe->shirt = NULL;
2854 skinframe->nmap = NULL;
2855 skinframe->gloss = NULL;
2856 skinframe->glow = NULL;
2857 skinframe->fog = NULL;
2858 skinframe->reflect = NULL;
2859 skinframe->hasalpha = (textureflags & TEXF_ALPHA) != 0;
2860 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2861 if (!tex)
2862 return NULL;
2864 Con_Printf("loading 32bit skin \"%s\"\n", name);
2865 skinframe->base = skinframe->merged = tex;
2866 Vector4Set(skinframe->avgcolor, 1, 1, 1, 1); // bogus placeholder
2867 return skinframe;
2868}

◆ R_SkinFrame_LoadMissing()

skinframe_t * R_SkinFrame_LoadMissing ( void  )

Definition at line 2803 of file gl_rmain.c.

2804{
2805 skinframe_t *skinframe;
2806
2807 if (cls.state == ca_dedicated)
2808 return NULL;
2809
2810 skinframe = R_SkinFrame_Find("missing", TEXF_FORCENEAREST, 0, 0, 0, true);
2811 skinframe->stain = NULL;
2812 skinframe->merged = NULL;
2813 skinframe->base = NULL;
2814 skinframe->pants = NULL;
2815 skinframe->shirt = NULL;
2816 skinframe->nmap = NULL;
2817 skinframe->gloss = NULL;
2818 skinframe->glow = NULL;
2819 skinframe->fog = NULL;
2820 skinframe->reflect = NULL;
2821 skinframe->hasalpha = false;
2822
2823 skinframe->avgcolor[0] = rand() / RAND_MAX;
2824 skinframe->avgcolor[1] = rand() / RAND_MAX;
2825 skinframe->avgcolor[2] = rand() / RAND_MAX;
2826 skinframe->avgcolor[3] = 1;
2827
2828 return skinframe;
2829}

Referenced by Mod_BuildAliasSkinsFromSkinFiles(), Mod_IDP2_Load(), Mod_IDS2_Load(), Mod_LoadTextureFromQ3Shader(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), and Mod_SpriteSetupTexture().

◆ R_SkinFrame_LoadNoTexture()

skinframe_t * R_SkinFrame_LoadNoTexture ( void  )

Definition at line 2831 of file gl_rmain.c.

2832{
2833 if (cls.state == ca_dedicated)
2834 return NULL;
2835
2836 return R_SkinFrame_LoadInternalBGRA("notexture", TEXF_FORCENEAREST, Image_GenerateNoTexture(), 16, 16, 0, 0, 0, false);
2837}
skinframe_t * R_SkinFrame_LoadInternalBGRA(const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qbool sRGB)
Definition gl_rmain.c:2545

◆ R_SkinFrame_MarkUsed()

void R_SkinFrame_MarkUsed ( skinframe_t skinframe)

Definition at line 2175 of file gl_rmain.c.

2176{
2177 if (!skinframe)
2178 return;
2179 // mark the skinframe as used for the purging code
2181}
unsigned int loadsequence
Definition r_textures.h:151

Referenced by Draw_CachePic_Flags(), Draw_NewPic(), gl_draw_newmap(), mod_newmap(), r_lightningbeams_newmap(), r_part_newmap(), r_shadow_newmap(), and R_SkinFrame_Find().

◆ R_SkinFrame_PrepareForPurge()

void R_SkinFrame_PrepareForPurge ( void  )

Definition at line 2167 of file gl_rmain.c.

2168{
2170 // wrap it without hitting zero
2171 if (r_skinframe.loadsequence >= 200)
2173}

Referenced by R_Modules_NewMap().

◆ R_SkinFrame_Purge()

void R_SkinFrame_Purge ( void  )

Definition at line 2202 of file gl_rmain.c.

2203{
2204 int i;
2205 skinframe_t *s;
2206 for (i = 0;i < SKINFRAME_HASH;i++)
2207 {
2208 for (s = r_skinframe.hash[i];s;s = s->next)
2209 {
2212 }
2213 }
2214}

Referenced by R_Modules_NewMap().

◆ R_SkinFrame_PurgeSkinFrame()

void R_SkinFrame_PurgeSkinFrame ( skinframe_t s)

Definition at line 2183 of file gl_rmain.c.

2184{
2185 if (s == NULL)
2186 return;
2187 if (s->merged == s->base)
2188 s->merged = NULL;
2189 R_PurgeTexture(s->stain); s->stain = NULL;
2190 R_PurgeTexture(s->merged); s->merged = NULL;
2191 R_PurgeTexture(s->base); s->base = NULL;
2192 R_PurgeTexture(s->pants); s->pants = NULL;
2193 R_PurgeTexture(s->shirt); s->shirt = NULL;
2194 R_PurgeTexture(s->nmap); s->nmap = NULL;
2195 R_PurgeTexture(s->gloss); s->gloss = NULL;
2196 R_PurgeTexture(s->glow); s->glow = NULL;
2197 R_PurgeTexture(s->fog); s->fog = NULL;
2199 s->loadsequence = 0;
2200}
void R_PurgeTexture(rtexture_t *rt)

Referenced by Draw_CachePic_Flags(), Draw_Frame(), Draw_FreePic(), Draw_NewPic(), Mod_UnloadCustomMaterial(), R_SkinFrame_Find(), R_SkinFrame_Purge(), and R_UnloadSkyBox().

◆ R_SortEntities()

static void R_SortEntities ( void  )
static

Definition at line 5628 of file gl_rmain.c.

5629{
5630 // below or equal 2 ents, sorting never gains anything
5631 if(r_refdef.scene.numentities <= 2)
5632 return;
5633 // sort
5635}
static int R_SortEntities_Compare(const void *ap, const void *bp)
Definition gl_rmain.c:5606

Referenced by R_RenderView().

◆ R_SortEntities_Compare()

static int R_SortEntities_Compare ( const void ap,
const void bp 
)
static

Definition at line 5606 of file gl_rmain.c.

5607{
5608 const entity_render_t *a = *(const entity_render_t **)ap;
5609 const entity_render_t *b = *(const entity_render_t **)bp;
5610
5611 // 1. compare model
5612 if(a->model < b->model)
5613 return -1;
5614 if(a->model > b->model)
5615 return +1;
5616
5617 // 2. compare skin
5618 // TODO possibly calculate the REAL skinnum here first using
5619 // skinscenes?
5620 if(a->skinnum < b->skinnum)
5621 return -1;
5622 if(a->skinnum > b->skinnum)
5623 return +1;
5624
5625 // everything we compared is equal
5626 return 0;
5627}

Referenced by R_SortEntities().

◆ R_tcMod_ApplyToMatrix()

static void R_tcMod_ApplyToMatrix ( matrix4x4_t texmatrix,
q3shaderinfo_layer_tcmod_t tcmod,
int  currentmaterialflags 
)
static

Definition at line 6481 of file gl_rmain.c.

6482{
6483 int w, h, idx;
6484 float shadertime;
6485 float f;
6486 float offsetd[2];
6487 float tcmat[12];
6488 matrix4x4_t matrix, temp;
6489 // if shadertime exceeds about 9 hours (32768 seconds), just wrap it,
6490 // it's better to have one huge fixup every 9 hours than gradual
6491 // degradation over time which looks consistently bad after many hours.
6492 //
6493 // tcmod scroll in particular suffers from this degradation which can't be
6494 // effectively worked around even with floor() tricks because we don't
6495 // know if tcmod scroll is the last tcmod being applied, and for clampmap
6496 // a workaround involving floor() would be incorrect anyway...
6497 shadertime = rsurface.shadertime;
6498 if (shadertime >= 32768.0f)
6499 shadertime -= floor(rsurface.shadertime * (1.0f / 32768.0f)) * 32768.0f;
6500 switch(tcmod->tcmod)
6501 {
6502 case Q3TCMOD_COUNT:
6503 case Q3TCMOD_NONE:
6504 if (currentmaterialflags & MATERIALFLAG_WATERSCROLL)
6505 matrix = r_waterscrollmatrix;
6506 else
6507 matrix = identitymatrix;
6508 break;
6510 // this is used in Q3 to allow the gamecode to control texcoord
6511 // scrolling on the entity, which is not supported in darkplaces yet.
6512 Matrix4x4_CreateTranslate(&matrix, 0, 0, 0);
6513 break;
6514 case Q3TCMOD_ROTATE:
6515 Matrix4x4_CreateTranslate(&matrix, 0.5, 0.5, 0);
6516 Matrix4x4_ConcatRotate(&matrix, tcmod->parms[0] * rsurface.shadertime, 0, 0, 1);
6517 Matrix4x4_ConcatTranslate(&matrix, -0.5, -0.5, 0);
6518 break;
6519 case Q3TCMOD_SCALE:
6520 Matrix4x4_CreateScale3(&matrix, tcmod->parms[0], tcmod->parms[1], 1);
6521 break;
6522 case Q3TCMOD_SCROLL:
6523 // this particular tcmod is a "bug for bug" compatible one with regards to
6524 // Quake3, the wrapping is unnecessary with our shadetime fix but quake3
6525 // specifically did the wrapping and so we must mimic that...
6526 offsetd[0] = tcmod->parms[0] * rsurface.shadertime;
6527 offsetd[1] = tcmod->parms[1] * rsurface.shadertime;
6528 Matrix4x4_CreateTranslate(&matrix, offsetd[0] - floor(offsetd[0]), offsetd[1] - floor(offsetd[1]), 0);
6529 break;
6530 case Q3TCMOD_PAGE: // poor man's animmap (to store animations into a single file, useful for HTTP downloaded textures)
6531 w = (int) tcmod->parms[0];
6532 h = (int) tcmod->parms[1];
6533 f = rsurface.shadertime / (tcmod->parms[2] * w * h);
6534 f = f - floor(f);
6535 idx = (int) floor(f * w * h);
6536 Matrix4x4_CreateTranslate(&matrix, (idx % w) / tcmod->parms[0], (idx / w) / tcmod->parms[1], 0);
6537 break;
6538 case Q3TCMOD_STRETCH:
6539 f = 1.0f / R_EvaluateQ3WaveFunc(tcmod->wavefunc, tcmod->waveparms);
6540 Matrix4x4_CreateFromQuakeEntity(&matrix, 0.5f * (1 - f), 0.5 * (1 - f), 0, 0, 0, 0, f);
6541 break;
6542 case Q3TCMOD_TRANSFORM:
6543 VectorSet(tcmat + 0, tcmod->parms[0], tcmod->parms[1], 0);
6544 VectorSet(tcmat + 3, tcmod->parms[2], tcmod->parms[3], 0);
6545 VectorSet(tcmat + 6, 0 , 0 , 1);
6546 VectorSet(tcmat + 9, tcmod->parms[4], tcmod->parms[5], 0);
6548 break;
6549 case Q3TCMOD_TURBULENT:
6550 // this is handled in the RSurf_PrepareVertices function
6551 matrix = identitymatrix;
6552 break;
6553 }
6554 temp = *texmatrix;
6555 Matrix4x4_Concat(texmatrix, &matrix, &temp);
6556}
static float R_EvaluateQ3WaveFunc(q3wavefunc_t func, const float *parms)
Definition gl_rmain.c:6443
void Matrix4x4_FromArray12FloatGL(matrix4x4_t *out, const float in[12])
Definition matrixlib.c:1352
void Matrix4x4_CreateScale3(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:695
void Matrix4x4_ConcatTranslate(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:1757
void Matrix4x4_ConcatRotate(matrix4x4_t *out, double angle, double x, double y, double z)
Definition matrixlib.c:1766
@ Q3TCMOD_SCALE
Definition r_qshader.h:114
@ Q3TCMOD_ROTATE
Definition r_qshader.h:113
@ Q3TCMOD_ENTITYTRANSLATE
Definition r_qshader.h:112
@ Q3TCMOD_TRANSFORM
Definition r_qshader.h:117
@ Q3TCMOD_SCROLL
Definition r_qshader.h:115
@ Q3TCMOD_PAGE
Definition r_qshader.h:119
@ Q3TCMOD_TURBULENT
Definition r_qshader.h:118
@ Q3TCMOD_STRETCH
Definition r_qshader.h:116
@ Q3TCMOD_NONE
Definition r_qshader.h:111
@ Q3TCMOD_COUNT
Definition r_qshader.h:120
float parms[Q3TCMOD_MAXPARMS]
Definition r_qshader.h:152
float waveparms[Q3WAVEPARMS]
Definition r_qshader.h:154

Referenced by R_GetCurrentTexture().

◆ R_TestQ3WaveFunc()

static qbool R_TestQ3WaveFunc ( q3wavefunc_t  func,
const float parms 
)
static

Definition at line 6433 of file gl_rmain.c.

6434{
6435 if(parms[0] == 0 && parms[1] == 0)
6436 return false;
6437 if(func >> Q3WAVEFUNC_USER_SHIFT) // assumes rsurface to be set!
6439 return false;
6440 return true;
6441}

Referenced by RSurf_PrepareVerticesForBatch().

◆ R_UpdateFog()

void R_UpdateFog ( void  )

Definition at line 5404 of file gl_rmain.c.

5405{
5406 // Nehahra fog
5407 if (gamemode == GAME_NEHAHRA)
5408 {
5410 {
5416 r_refdef.fog_alpha = 1;
5417 r_refdef.fog_start = 0;
5419 r_refdef.fog_height = 1<<30;
5420 r_refdef.fog_fadedepth = 128;
5421 }
5422 else if (r_refdef.oldgl_fogenable)
5423 {
5424 r_refdef.oldgl_fogenable = false;
5426 r_refdef.fog_red = 0;
5427 r_refdef.fog_green = 0;
5428 r_refdef.fog_blue = 0;
5429 r_refdef.fog_alpha = 0;
5430 r_refdef.fog_start = 0;
5431 r_refdef.fog_end = 0;
5432 r_refdef.fog_height = 1<<30;
5433 r_refdef.fog_fadedepth = 128;
5434 }
5435 }
5436
5437 // fog parms
5441
5443 {
5444 r_refdef.fogenabled = true;
5445 // this is the point where the fog reaches 0.9986 alpha, which we
5446 // consider a good enough cutoff point for the texture
5447 // (0.9986 * 256 == 255.6)
5448 if (r_fog_exp2.integer)
5450 else
5457 // fog color was already set
5458 // update the fog texture
5463 }
5464 else
5465 r_refdef.fogenabled = false;
5466
5467 // fog color
5469 {
5473
5478
5479 {
5480 vec3_t fogvec;
5482 // color.rgb *= ContrastBoost * SceneBrightness;
5484 r_refdef.fogcolor[0] = bound(0.0f, fogvec[0], 1.0f);
5485 r_refdef.fogcolor[1] = bound(0.0f, fogvec[1], 1.0f);
5486 r_refdef.fogcolor[2] = bound(0.0f, fogvec[2], 1.0f);
5487 }
5488 }
5489}
static void R_BuildFogTexture(void)
Definition gl_rmain.c:470
static void R_BuildFogHeightTexture(void)
Definition gl_rmain.c:526
float fogplaneviewdist
Definition render.h:426
float fog_height_texcoordscale
Definition render.h:454
qbool oldgl_fogenable
Definition render.h:446
float fog_height_tablescale
Definition render.h:453
float fogheightfade
Definition render.h:428
float fogmasktabledistmultiplier
Definition render.h:432
float fograngerecip
Definition render.h:431
float fogplane[4]
Definition render.h:425

Referenced by R_ClearScreen(), and R_RenderScene().

◆ R_UpdateVariables()

void R_UpdateVariables ( void  )

Definition at line 5491 of file gl_rmain.c.

5492{
5494
5495 r_refdef.scene.ambientintensity = r_ambient.value * (1.0f / 64.0f);
5496
5501
5506
5513 {
5515
5516 // Apply the default lightstyle to the lightmap even on q3bsp
5517 if (cl.worldmodel && cl.worldmodel->type == mod_brushq3) {
5519 }
5520 }
5522 {
5523 r_refdef.scene.rtworld = false;
5525 r_refdef.scene.rtdlight = false;
5528 }
5529
5530 r_gpuskeletal = false;
5531 switch(vid.renderpath)
5532 {
5533 case RENDERPATH_GL32:
5535 case RENDERPATH_GLES2:
5537 {
5539 {
5540 // build GLSL gamma texture
5541#define RAMPWIDTH 256
5542 unsigned short ramp[RAMPWIDTH * 3];
5543 unsigned char rampbgr[RAMPWIDTH][4];
5544 int i;
5545
5547
5549 for(i = 0; i < RAMPWIDTH; ++i)
5550 {
5551 rampbgr[i][0] = (unsigned char) (ramp[i + 2 * RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
5552 rampbgr[i][1] = (unsigned char) (ramp[i + RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
5553 rampbgr[i][2] = (unsigned char) (ramp[i] * 255.0 / 65535.0 + 0.5);
5554 rampbgr[i][3] = 0;
5555 }
5557 {
5558 R_UpdateTexture(r_texture_gammaramps, &rampbgr[0][0], 0, 0, 0, RAMPWIDTH, 1, 1, 0);
5559 }
5560 else
5561 {
5563 }
5564 }
5565 }
5566 else
5567 {
5568 // remove GLSL gamma texture
5569 }
5570 break;
5571 }
5572}
unsigned int r_texture_gammaramps_serial
Definition gl_rmain.c:282
#define RAMPWIDTH
cvar_t r_ambient
Definition gl_rsurf.c:28
void R_Textures_Frame(void)
cvar_t r_shadow_realtime_dlight
Definition r_shadow.c:159
cvar_t r_shadow_realtime_world_shadows
Definition r_shadow.c:166
cvar_t r_shadow_realtime_world
Definition r_shadow.c:163
cvar_t r_shadow_realtime_dlight_shadows
Definition r_shadow.c:160
cvar_t r_shadow_realtime_world_lightmaps
Definition r_shadow.c:165
cvar_t gl_flashblend
Definition r_shadow.c:236
@ mod_brushq3
cvar_t r_shadow_frontsidecasting
Definition r_shadow.c:158
float radius
float lightmapscale
float rtlightstylevalue[MAX_LIGHTSTYLES]
float fraction of base light value
Definition render.h:382
qbool rtworldshadows
Definition render.h:395
qbool rtdlightshadows
Definition render.h:397
unsigned int vid_gammatables_serial
void VID_BuildGammaTables(unsigned short *ramps, int rampsize)

Referenced by R_Envmap_f(), and SCR_DrawScreen().

◆ R_View_SetFrustum()

static void R_View_SetFrustum ( const int scissor)
static

Definition at line 4197 of file gl_rmain.c.

4198{
4199 int i;
4200 double fpx = +1, fnx = -1, fpy = +1, fny = -1;
4201 vec3_t forward, left, up, origin, v;
4203 return;
4204 if(scissor)
4205 {
4206 // flipped x coordinates (because x points left here)
4207 fpx = 1.0 - 2.0 * (scissor[0] - r_refdef.view.viewport.x) / (double) (r_refdef.view.viewport.width);
4208 fnx = 1.0 - 2.0 * (scissor[0] + scissor[2] - r_refdef.view.viewport.x) / (double) (r_refdef.view.viewport.width);
4209 // non-flipped y coordinates
4210 fny = -1.0 + 2.0 * (scissor[1] - r_refdef.view.viewport.y) / (double) (r_refdef.view.viewport.height);
4211 fpy = -1.0 + 2.0 * (scissor[1] + scissor[3] - r_refdef.view.viewport.y) / (double) (r_refdef.view.viewport.height);
4212 }
4213
4214 // we can't trust r_refdef.view.forward and friends in reflected scenes
4216
4217#if 0
4218 r_refdef.view.frustum[0].normal[0] = 0 - 1.0 / r_refdef.view.frustum_x;
4219 r_refdef.view.frustum[0].normal[1] = 0 - 0;
4220 r_refdef.view.frustum[0].normal[2] = -1 - 0;
4221 r_refdef.view.frustum[1].normal[0] = 0 + 1.0 / r_refdef.view.frustum_x;
4222 r_refdef.view.frustum[1].normal[1] = 0 + 0;
4223 r_refdef.view.frustum[1].normal[2] = -1 + 0;
4224 r_refdef.view.frustum[2].normal[0] = 0 - 0;
4225 r_refdef.view.frustum[2].normal[1] = 0 - 1.0 / r_refdef.view.frustum_y;
4226 r_refdef.view.frustum[2].normal[2] = -1 - 0;
4227 r_refdef.view.frustum[3].normal[0] = 0 + 0;
4228 r_refdef.view.frustum[3].normal[1] = 0 + 1.0 / r_refdef.view.frustum_y;
4229 r_refdef.view.frustum[3].normal[2] = -1 + 0;
4230#endif
4231
4232#if 0
4234 nudge = 1.0 - 1.0 / (1<<23);
4235 r_refdef.view.frustum[4].normal[0] = 0 - 0;
4236 r_refdef.view.frustum[4].normal[1] = 0 - 0;
4237 r_refdef.view.frustum[4].normal[2] = -1 - -nudge;
4238 r_refdef.view.frustum[4].dist = 0 - -2 * zNear * nudge;
4239 r_refdef.view.frustum[5].normal[0] = 0 + 0;
4240 r_refdef.view.frustum[5].normal[1] = 0 + 0;
4241 r_refdef.view.frustum[5].normal[2] = -1 + -nudge;
4242 r_refdef.view.frustum[5].dist = 0 + -2 * zNear * nudge;
4243#endif
4244
4245
4246
4247#if 0
4248 r_refdef.view.frustum[0].normal[0] = m[3] - m[0];
4249 r_refdef.view.frustum[0].normal[1] = m[7] - m[4];
4250 r_refdef.view.frustum[0].normal[2] = m[11] - m[8];
4251 r_refdef.view.frustum[0].dist = m[15] - m[12];
4252
4253 r_refdef.view.frustum[1].normal[0] = m[3] + m[0];
4254 r_refdef.view.frustum[1].normal[1] = m[7] + m[4];
4255 r_refdef.view.frustum[1].normal[2] = m[11] + m[8];
4256 r_refdef.view.frustum[1].dist = m[15] + m[12];
4257
4258 r_refdef.view.frustum[2].normal[0] = m[3] - m[1];
4259 r_refdef.view.frustum[2].normal[1] = m[7] - m[5];
4260 r_refdef.view.frustum[2].normal[2] = m[11] - m[9];
4261 r_refdef.view.frustum[2].dist = m[15] - m[13];
4262
4263 r_refdef.view.frustum[3].normal[0] = m[3] + m[1];
4264 r_refdef.view.frustum[3].normal[1] = m[7] + m[5];
4265 r_refdef.view.frustum[3].normal[2] = m[11] + m[9];
4266 r_refdef.view.frustum[3].dist = m[15] + m[13];
4267
4268 r_refdef.view.frustum[4].normal[0] = m[3] - m[2];
4269 r_refdef.view.frustum[4].normal[1] = m[7] - m[6];
4270 r_refdef.view.frustum[4].normal[2] = m[11] - m[10];
4271 r_refdef.view.frustum[4].dist = m[15] - m[14];
4272
4273 r_refdef.view.frustum[5].normal[0] = m[3] + m[2];
4274 r_refdef.view.frustum[5].normal[1] = m[7] + m[6];
4275 r_refdef.view.frustum[5].normal[2] = m[11] + m[10];
4276 r_refdef.view.frustum[5].dist = m[15] + m[14];
4277#endif
4278
4280 {
4281 // calculate frustum corners, which are used to calculate deformed frustum planes for shadow caster culling
4282 VectorMAMAM(1024, forward, fnx * 1024.0 * r_refdef.view.frustum_x, left, fny * 1024.0 * r_refdef.view.frustum_y, up, r_refdef.view.frustumcorner[0]);
4283 VectorMAMAM(1024, forward, fpx * 1024.0 * r_refdef.view.frustum_x, left, fny * 1024.0 * r_refdef.view.frustum_y, up, r_refdef.view.frustumcorner[1]);
4284 VectorMAMAM(1024, forward, fnx * 1024.0 * r_refdef.view.frustum_x, left, fpy * 1024.0 * r_refdef.view.frustum_y, up, r_refdef.view.frustumcorner[2]);
4285 VectorMAMAM(1024, forward, fpx * 1024.0 * r_refdef.view.frustum_x, left, fpy * 1024.0 * r_refdef.view.frustum_y, up, r_refdef.view.frustumcorner[3]);
4286
4287 // then the normals from the corners relative to origin
4292
4293 // in a NORMAL view, forward cross left == up
4294 // in a REFLECTED view, forward cross left == down
4295 // so our cross products above need to be adjusted for a left handed coordinate system
4296 CrossProduct(forward, left, v);
4297 if(DotProduct(v, up) < 0)
4298 {
4303 }
4304
4305 // Leaving those out was a mistake, those were in the old code, and they
4306 // fix a reproducable bug in this one: frustum culling got fucked up when viewmatrix was an identity matrix
4307 // I couldn't reproduce it after adding those normalizations. --blub
4312
4313 // make the corners absolute
4318
4319 // one more normal
4321
4327 }
4328 else
4329 {
4330 VectorScale(left, -1.0f, r_refdef.view.frustum[0].normal);
4331 VectorScale(left, 1.0f, r_refdef.view.frustum[1].normal);
4340 }
4342
4344 {
4347 }
4348
4349 for (i = 0;i < r_refdef.view.numfrustumplanes;i++)
4351
4352 // LadyHavoc: note to all quake engine coders, Quake had a special case
4353 // for 90 degrees which assumed a square view (wrong), so I removed it,
4354 // Quake2 has it disabled as well.
4355
4356 // rotate R_VIEWFORWARD right by FOV_X/2 degrees
4357 //RotatePointAroundVector( r_refdef.view.frustum[0].normal, up, forward, -(90 - r_refdef.fov_x / 2));
4358 //r_refdef.view.frustum[0].dist = DotProduct (r_refdef.view.origin, frustum[0].normal);
4359 //PlaneClassify(&frustum[0]);
4360
4361 // rotate R_VIEWFORWARD left by FOV_X/2 degrees
4362 //RotatePointAroundVector( r_refdef.view.frustum[1].normal, up, forward, (90 - r_refdef.fov_x / 2));
4363 //r_refdef.view.frustum[1].dist = DotProduct (r_refdef.view.origin, frustum[1].normal);
4364 //PlaneClassify(&frustum[1]);
4365
4366 // rotate R_VIEWFORWARD up by FOV_X/2 degrees
4367 //RotatePointAroundVector( r_refdef.view.frustum[2].normal, left, forward, -(90 - r_refdef.fov_y / 2));
4368 //r_refdef.view.frustum[2].dist = DotProduct (r_refdef.view.origin, frustum[2].normal);
4369 //PlaneClassify(&frustum[2]);
4370
4371 // rotate R_VIEWFORWARD down by FOV_X/2 degrees
4372 //RotatePointAroundVector( r_refdef.view.frustum[3].normal, left, forward, (90 - r_refdef.fov_y / 2));
4373 //r_refdef.view.frustum[3].dist = DotProduct (r_refdef.view.origin, frustum[3].normal);
4374 //PlaneClassify(&frustum[3]);
4375
4376 // nearclip plane
4377 //VectorCopy(forward, r_refdef.view.frustum[4].normal);
4378 //r_refdef.view.frustum[4].dist = DotProduct (r_refdef.view.origin, frustum[4].normal) + r_nearclip.value;
4379 //PlaneClassify(&frustum[4]);
4380}
cvar_t r_lockvisibility
Definition gl_rsurf.c:30
void PlaneClassify(mplane_t *p)
Definition mathlib.c:310
#define VectorAdd(a, b, c)
Definition mathlib.h:99
#define VectorMAMAM(scale1, b1, scale2, b2, scale3, b3, c)
Definition mathlib.h:116
vec3_t frustumcorner[4]
Definition render.h:278

Referenced by R_View_Update().

◆ R_View_Update()

static void R_View_Update ( const int myscissor)
static

Definition at line 4382 of file gl_rmain.c.

4383{
4388}
static void R_View_UpdateEntityVisible(void)
Definition gl_rmain.c:4000
static void R_View_SetFrustum(const int *scissor)
Definition gl_rmain.c:4197
static void R_Main_ResizeViewCache(void)
Definition gl_rmain.c:3010
void R_View_WorldVisibility(qbool forcenovis)
Definition gl_rsurf.c:436

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_View_UpdateEntityVisible()

static void R_View_UpdateEntityVisible ( void  )
static

Definition at line 4000 of file gl_rmain.c.

4001{
4002 int i;
4003 int renderimask;
4004 int samples;
4005 entity_render_t *ent;
4006
4011 else
4019 {
4020 // worldmodel can check visibility
4021 for (i = 0;i < r_refdef.scene.numentities;i++)
4022 {
4023 ent = r_refdef.scene.entities[i];
4025 {
4027 continue;
4028 }
4029 if (!(ent->flags & renderimask))
4030 if (!R_CullFrustum(ent->mins, ent->maxs) || (ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)))
4033 }
4034 }
4035 else
4036 {
4037 // no worldmodel or it can't check visibility
4038 for (i = 0;i < r_refdef.scene.numentities;i++)
4039 {
4040 ent = r_refdef.scene.entities[i];
4041 if (!(ent->flags & renderimask))
4042 if (!R_CullFrustum(ent->mins, ent->maxs) || (ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)))
4044 }
4045 }
4047 {
4048 for (i = 0;i < r_refdef.scene.numentities;i++)
4049 {
4051 continue;
4052 ent = r_refdef.scene.entities[i];
4053 if (!(ent->flags & (RENDER_VIEWMODEL | RENDER_WORLDOBJECT | RENDER_NODEPTHTEST)) && !(ent->model && (ent->model->name[0] == '*')))
4054 {
4060 }
4061 }
4062 }
4063}
qbool R_CanSeeBox(int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t entboxexpand, vec_t pad, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
Definition gl_rmain.c:3896
GLsizei samples
Definition glquake.h:622
@ mod_sprite
#define RENDER_EXTERIORMODEL
Definition protocol.h:360
cvar_t chase_active
Definition view.c:132
#define SPR_LABEL
Definition spritegn.h:101
#define SPR_LABEL_SCALE
Definition spritegn.h:102
double last_trace_visibility
Definition client.h:443
int(* BoxTouchingVisibleLeafs)(struct model_s *model, const unsigned char *visibleleafs, const vec3_t mins, const vec3_t maxs)
model_sprite_t sprite
modtype_t type
char name[MAX_QPATH]
qbool world_novis
if true, the view is currently in a leaf without pvs data
Definition render.h:346
qbool hideplayer
Definition render.h:882

Referenced by R_View_Update().

◆ R_Water_AddWaterPlane()

void R_Water_AddWaterPlane ( msurface_t surface,
int  entno 
)

Definition at line 4648 of file gl_rmain.c.

4649{
4650 int planeindex, bestplaneindex, vertexindex;
4651 vec3_t mins, maxs, normal, center, v, n;
4653 mplane_t plane;
4655 texture_t *t = R_GetCurrentTexture(surface->texture);
4656
4657 rsurface.texture = t;
4659 // if the model has no normals, it's probably off-screen and they were not generated, so don't add it anyway
4661 return;
4662 // average the vertex normals, find the surface bounds (after deformvertexes)
4666 VectorCopy(v, mins);
4667 VectorCopy(v, maxs);
4669 {
4673 mins[0] = min(mins[0], v[0]);
4674 mins[1] = min(mins[1], v[1]);
4675 mins[2] = min(mins[2], v[2]);
4676 maxs[0] = max(maxs[0], v[0]);
4677 maxs[1] = max(maxs[1], v[1]);
4678 maxs[2] = max(maxs[2], v[2]);
4679 }
4681 VectorMAM(0.5f, mins, 0.5f, maxs, center);
4682
4683 VectorCopy(normal, plane.normal);
4684 VectorNormalize(plane.normal);
4685 plane.dist = DotProduct(center, plane.normal);
4686 PlaneClassify(&plane);
4687 if (PlaneDiff(r_refdef.view.origin, &plane) < 0)
4688 {
4689 // skip backfaces (except if nocullface is set)
4690// if (!(t->currentmaterialflags & MATERIALFLAG_NOCULLFACE))
4691// return;
4692 VectorNegate(plane.normal, plane.normal);
4693 plane.dist *= -1;
4694 PlaneClassify(&plane);
4695 }
4696
4697
4698 // find a matching plane if there is one
4699 bestplaneindex = -1;
4700 bestplanescore = 1048576.0f;
4701 for (planeindex = 0, p = r_fb.water.waterplanes;planeindex < r_fb.water.numwaterplanes;planeindex++, p++)
4702 {
4703 if(p->camera_entity == t->camera_entity)
4704 {
4705 planescore = 1.0f - DotProduct(plane.normal, p->plane.normal) + fabs(plane.dist - p->plane.dist) * 0.001f;
4707 {
4708 bestplaneindex = planeindex;
4710 }
4711 }
4712 }
4713 planeindex = bestplaneindex;
4714
4715 // if this surface does not fit any known plane rendered this frame, add one
4717 {
4719 {
4720 // store the new plane
4721 planeindex = r_fb.water.numwaterplanes++;
4722 p = r_fb.water.waterplanes + planeindex;
4723 p->plane = plane;
4724 // clear materialflags and pvs
4725 p->materialflags = 0;
4726 p->pvsvalid = false;
4728 VectorCopy(mins, p->mins);
4729 VectorCopy(maxs, p->maxs);
4730 }
4731 else
4732 {
4733 // We're totally screwed.
4734 return;
4735 }
4736 }
4737 else
4738 {
4739 // merge mins/maxs when we're adding this surface to the plane
4740 p = r_fb.water.waterplanes + planeindex;
4741 p->mins[0] = min(p->mins[0], mins[0]);
4742 p->mins[1] = min(p->mins[1], mins[1]);
4743 p->mins[2] = min(p->mins[2], mins[2]);
4744 p->maxs[0] = max(p->maxs[0], maxs[0]);
4745 p->maxs[1] = max(p->maxs[1], maxs[1]);
4746 p->maxs[2] = max(p->maxs[2], maxs[2]);
4747 }
4748 // merge this surface's materialflags into the waterplane
4751 {
4752 // merge this surface's PVS into the waterplane
4755 {
4757 p->pvsvalid = true;
4758 }
4759 }
4760}
#define PlaneDiff(point, plane)
Definition mathlib.h:256
int clusterindex
int(* FatPVS)(struct model_s *model, const vec3_t org, vec_t radius, unsigned char *pvsbuffer, int pvsbufferlength, qbool merge)
mleaf_t *(* PointInLeaf)(struct model_s *model, const vec3_t p)
int maxwaterplanes
Definition render.h:872
unsigned char pvsbits[(MAX_MAP_LEAFS+7)> >3]
Definition render.h:859

Referenced by R_Mod_DrawAddWaterPlanes().

◆ R_Water_ProcessPlanes()

static void R_Water_ProcessPlanes ( int  fbo,
rtexture_t depthtexture,
rtexture_t colortexture,
int  viewx,
int  viewy,
int  viewwidth,
int  viewheight 
)
static

Definition at line 4765 of file gl_rmain.c.

4766{
4767 int myscissor[4];
4770 int planeindex, qualityreduction = 0, old_r_dynamic = 0, old_r_shadows = 0, old_r_worldrtlight = 0, old_r_dlight = 0, old_r_particles = 0, old_r_decals = 0;
4774
4776
4777 // lowquality hack, temporarily shut down some cvars and restore afterwards
4778 qualityreduction = r_water_lowquality.integer;
4779 if (qualityreduction > 0)
4780 {
4781 if (qualityreduction >= 1)
4782 {
4789 }
4790 if (qualityreduction >= 2)
4791 {
4798 }
4799 }
4800
4801 for (planeindex = 0, p = r_fb.water.waterplanes; planeindex < r_fb.water.numwaterplanes; planeindex++, p++)
4802 {
4803 p->rt_reflection = NULL;
4804 p->rt_refraction = NULL;
4805 p->rt_camera = NULL;
4806 }
4807
4808 // render views
4810 r_refdef.view.showdebug = false;
4813 r_refdef.view.useclipplane = true;
4815 r_fb.water.renderingscene = true;
4816 for (planeindex = 0, p = r_fb.water.waterplanes;planeindex < r_fb.water.numwaterplanes;planeindex++, p++)
4817 {
4819 continue;
4820
4822 {
4824 if (rt->colortexture[0] == NULL || rt->depthtexture == NULL)
4825 goto error;
4830 {
4831 R_SetupView(true, rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, r_fb.water.waterwidth, r_fb.water.waterheight);
4832 if (R_ScissorForBBox(p->mins, p->maxs, myscissor))
4833 {
4834 p->rt_reflection = NULL;
4835 p->rt_refraction = NULL;
4836 p->rt_camera = NULL;
4837 continue;
4838 }
4839 }
4840
4842 // reflected view origin may be in solid, so don't cull with it
4844 // reverse the cullface settings for this render
4847 // combined pvs (based on what can be seen from each surface center)
4849 {
4850 r_refdef.view.usecustompvs = true;
4851 if (p->pvsvalid)
4853 else
4855 }
4856
4858 R_ResetViewRendering3D(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4859 GL_ScissorTest(false);
4861 GL_ScissorTest(true);
4866 R_RenderScene(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4867
4868 r_fb.water.hideplayer = false;
4869 p->rt_reflection = rt;
4870 }
4871
4872 // render the normal view scene and copy into texture
4873 // (except that a clipping plane should be used to hide everything on one side of the water, and the viewer's weapon model should be omitted)
4875 {
4877 if (rt->colortexture[0] == NULL || rt->depthtexture == NULL)
4878 goto error;
4881 {
4882 R_SetupView(true, rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, r_fb.water.waterwidth, r_fb.water.waterheight);
4883 if (R_ScissorForBBox(p->mins, p->maxs, myscissor))
4884 {
4885 p->rt_reflection = NULL;
4886 p->rt_refraction = NULL;
4887 p->rt_camera = NULL;
4888 continue;
4889 }
4890 }
4891
4892 // combined pvs (based on what can be seen from each surface center)
4894 {
4895 r_refdef.view.usecustompvs = true;
4896 if (p->pvsvalid)
4898 else
4900 }
4901
4903
4907
4909 {
4910 // we need to perform a matrix transform to render the view... so let's get the transformation matrix
4911 r_fb.water.hideplayer = false; // we don't want to hide the player model from these ones
4915 {
4916 r_refdef.view.usecustompvs = true;
4918 }
4919 }
4920
4922
4923 R_ResetViewRendering3D(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4924 GL_ScissorTest(false);
4926 GL_ScissorTest(true);
4931 R_RenderScene(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4932
4933 r_fb.water.hideplayer = false;
4934 p->rt_refraction = rt;
4935 }
4936 else if (p->materialflags & MATERIALFLAG_CAMERA)
4937 {
4939 if (rt->colortexture[0] == NULL || rt->depthtexture == NULL)
4940 goto error;
4942
4946
4949 r_refdef.view.frustum_x = 1; // tan(45 * M_PI / 180.0);
4950 r_refdef.view.frustum_y = 1; // tan(45 * M_PI / 180.0);
4951 r_refdef.view.ortho_x = 90; // abused as angle by VM_CL_R_SetView
4952 r_refdef.view.ortho_y = 90; // abused as angle by VM_CL_R_SetView
4953
4954 if(p->camera_entity)
4955 {
4956 // we need to perform a matrix transform to render the view... so let's get the transformation matrix
4958 }
4959
4960 // note: all of the view is used for displaying... so
4961 // there is no use in scissoring
4962
4963 // reverse the cullface settings for this render
4966 // also reverse the view matrix
4967 Matrix4x4_ConcatScale3(&r_refdef.view.matrix, 1, 1, -1); // this serves to invert texcoords in the result, as the copied texture is mapped the wrong way round
4970 {
4971 r_refdef.view.usecustompvs = true;
4973 }
4974
4975 // camera needs no clipplane
4976 r_refdef.view.useclipplane = false;
4977 // TODO: is the camera origin always valid? if so we don't need to clear this
4979
4981
4982 r_fb.water.hideplayer = false;
4983
4984 R_ResetViewRendering3D(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4985 GL_ScissorTest(false);
4987 GL_ScissorTest(true);
4990 R_RenderScene(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4991
4992 r_fb.water.hideplayer = false;
4993 p->rt_camera = rt;
4994 }
4995
4996 }
4997 r_fb.water.renderingscene = false;
4999 R_ResetViewRendering3D(fbo, depthtexture, colortexture, viewx, viewy, viewwidth, viewheight);
5002 goto finish;
5003error:
5005 r_fb.water.renderingscene = false;
5007 Con_Printf("R_Water_ProcessPlanes: Error: texture creation failed! Turned off r_water.\n");
5008finish:
5009 // lowquality hack, restore cvars
5010 if (qualityreduction > 0)
5011 {
5012 if (qualityreduction >= 1)
5013 {
5017 }
5018 if (qualityreduction >= 2)
5019 {
5023 }
5024 }
5025}
qbool CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clipplane, vec3_t visorigin)
Definition csprogs.c:1140
cvar_t r_drawparticles
#define GL_BACK
Definition glquake.h:133
#define GL_FRONT
Definition glquake.h:132
void Matrix4x4_ConcatScale3(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:1784
void Matrix4x4_Reflect(matrix4x4_t *out, double normalx, double normaly, double normalz, double dist, double axisscale)
Definition matrixlib.c:535
qbool usecustompvs
uses r_refdef.viewcache.pvsbits as-is rather than computing it
Definition render.h:275
int cullface_front
Definition render.h:317
int cameraheight
Definition render.h:870
int camerawidth
Definition render.h:870
int waterheight
Definition render.h:868
r_rendertarget_t * rt_refraction
Definition render.h:854
r_rendertarget_t * rt_camera
Definition render.h:856
r_rendertarget_t * rt_reflection
Definition render.h:855

Referenced by R_RenderWaterPlanes().

◆ R_Water_StartFrame()

static void R_Water_StartFrame ( int  viewwidth,
int  viewheight 
)
static

Definition at line 4616 of file gl_rmain.c.

4617{
4618 int waterwidth, waterheight;
4619
4621 return;
4622
4623 // set waterwidth and waterheight to the water resolution that will be
4624 // used (often less than the screen resolution for faster rendering)
4627
4629 waterwidth = waterheight = 0;
4630
4631 // set up variables that will be used in shader setup
4632 r_fb.water.waterwidth = waterwidth;
4633 r_fb.water.waterheight = waterheight;
4634 r_fb.water.texturewidth = waterwidth;
4635 r_fb.water.textureheight = waterheight;
4636 r_fb.water.camerawidth = waterwidth;
4637 r_fb.water.cameraheight = waterheight;
4638 r_fb.water.screenscale[0] = 0.5f;
4639 r_fb.water.screenscale[1] = 0.5f;
4640 r_fb.water.screencenter[0] = 0.5f;
4641 r_fb.water.screencenter[1] = 0.5f;
4642 r_fb.water.enabled = waterwidth != 0;
4643
4646}
cvar_t r_lockpvs
Definition gl_rsurf.c:29
#define MAX_WATERPLANES
max number of water planes visible (each one causes additional view renders)
Definition qdefs.h:129
int texturewidth
Definition render.h:869
int textureheight
Definition render.h:869

Referenced by R_RenderView().

◆ Render_Init()

void Render_Init ( void  )

Definition at line 3428 of file gl_rmain.c.

3429{
3432 GL_Main_Init();
3433 Font_Init();
3434 GL_Draw_Init();
3435 R_Shadow_Init();
3436 R_Sky_Init();
3437 GL_Surf_Init();
3438 Sbar_Init();
3444}
void CL_MeshEntities_Init(void)
Definition cl_main.c:2557
void R_Particles_Init(void)
void Font_Init(void)
Definition ft2.c:443
void gl_backend_init(void)
Definition gl_backend.c:340
void GL_Draw_Init(void)
Definition gl_draw.c:746
void GL_Main_Init(void)
Definition gl_rmain.c:3228
void GL_Surf_Init(void)
Definition gl_rsurf.c:1564
void R_Textures_Init(void)
void Mod_RenderInit(void)
void R_Explosion_Init(void)
void R_LightningBeams_Init(void)
Definition r_lightning.c:96
void R_Shadow_Init(void)
Definition r_shadow.c:601
void R_Sky_Init(void)
Definition r_sky.c:464
void Sbar_Init(void)
Definition sbar.c:360

Referenced by CL_Init().

◆ RSurf_ActiveCustomEntity()

void RSurf_ActiveCustomEntity ( const matrix4x4_t matrix,
const matrix4x4_t inversematrix,
int  entflags,
double  shadertime,
float  r,
float  g,
float  b,
float  a,
int  numvertices,
const float vertex3f,
const float texcoord2f,
const float normal3f,
const float svector3f,
const float tvector3f,
const float color4f,
int  numtriangles,
const int element3i,
const unsigned short element3s,
qbool  wantnormals,
qbool  wanttangents 
)

Definition at line 7182 of file gl_rmain.c.

7183{
7185 if (r != 1.0f || g != 1.0f || b != 1.0f || a != 1.0f) {
7186 // HACK to provide a valid entity with modded colors to R_GetCurrentTexture.
7187 // A better approach could be making this copy only once per frame.
7189 int q;
7191 for (q = 0; q < 3; ++q) {
7192 float colormod = q == 0 ? r : q == 1 ? g : b;
7193 custom_entity.render_fullbright[q] *= colormod;
7194 custom_entity.render_modellight_ambient[q] *= colormod;
7195 custom_entity.render_modellight_diffuse[q] *= colormod;
7196 custom_entity.render_lightmap_ambient[q] *= colormod;
7197 custom_entity.render_lightmap_diffuse[q] *= colormod;
7198 custom_entity.render_rtlight_diffuse[q] *= colormod;
7199 }
7200 custom_entity.alpha *= a;
7202 }
7205 rsurface.ent_qwskin = -1;
7207 rsurface.shadertime = r_refdef.scene.time - shadertime;
7208 rsurface.modelnumvertices = numvertices;
7209 rsurface.modelnumtriangles = numtriangles;
7210 rsurface.matrix = *matrix;
7211 rsurface.inversematrix = *inversematrix;
7222 rsurface.frameblend[0].lerp = 1;
7223 rsurface.ent_alttextures = false;
7235 if (wanttangents)
7236 {
7237 rsurface.modelvertex3f = (float *)vertex3f;
7238 rsurface.modelsvector3f = svector3f ? (float *)svector3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7239 rsurface.modeltvector3f = tvector3f ? (float *)tvector3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7240 rsurface.modelnormal3f = normal3f ? (float *)normal3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7241 }
7242 else if (wantnormals)
7243 {
7244 rsurface.modelvertex3f = (float *)vertex3f;
7247 rsurface.modelnormal3f = normal3f ? (float *)normal3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7248 }
7249 else
7250 {
7251 rsurface.modelvertex3f = (float *)vertex3f;
7255 }
7265 rsurface.modellightmapcolor4f = (float *)color4f;
7268 rsurface.modeltexcoordtexture2f = (float *)texcoord2f;
7280 rsurface.modelelement3i = (int *)element3i;
7283 rsurface.modelelement3s = (unsigned short *)element3s;
7327
7329 {
7330 if ((wantnormals || wanttangents) && !normal3f)
7331 {
7332 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7334 }
7335 if (wanttangents && !svector3f)
7336 {
7337 rsurface.modelsvector3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7338 rsurface.modeltvector3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7340 }
7341 }
7342}
void Matrix4x4_TransformStandardPlane(const matrix4x4_t *in, float x, float y, float z, float d, float *o)
Definition matrixlib.c:1717
double Matrix4x4_ScaleFromMatrix(const matrix4x4_t *in)
Definition matrixlib.c:1805
void Mod_BuildNormals(int firstvertex, int numvertices, int numtriangles, const float *vertex3f, const int *elements, float *normal3f, qbool areaweighting)
void Mod_BuildTextureVectorsFromNormals(int firstvertex, int numvertices, int numtriangles, const float *vertex3f, const float *texcoord2f, const float *normal3f, const int *elements, float *svector3f, float *tvector3f, qbool areaweighting)
@ r_stat_batch_entitycustom_surfaces
Definition r_stats.h:164
@ r_stat_batch_entitycustom_triangles
Definition r_stats.h:166
@ r_stat_batch_entitycustom_vertices
Definition r_stats.h:165
@ r_stat_batch_entitycustom_count
Definition r_stats.h:163
float lerp
Definition client.h:314
int batchskeletalindex4ub_bufferoffset
Definition render.h:701
int modelskeletalweight4ub_bufferoffset
Definition render.h:653
int * batchelement3i
Definition render.h:705
unsigned short * batchelement3s
Definition render.h:708
float * entityskeletaltransform3x4
Definition render.h:623
unsigned char * modelskeletalindex4ub
Definition render.h:648
int modeltvector3f_bufferoffset
Definition render.h:635
int batchskeletalweight4ub_bufferoffset
Definition render.h:704
int batchelement3s_bufferoffset
Definition render.h:710
float * batchtexcoordlightmap2f
Definition render.h:696
int batchnumtriangles
Definition render.h:677
int batchelement3i_bufferoffset
Definition render.h:707
int modelelement3i_bufferoffset
Definition render.h:656
const r_meshbuffer_t * batchtexcoordlightmap2f_vertexbuffer
Definition render.h:697
int modelsvector3f_bufferoffset
Definition render.h:632
unsigned short * modelelement3s
Definition render.h:657
int batchtexcoordlightmap2f_bufferoffset
Definition render.h:698
int modeltexcoordlightmap2f_bufferoffset
Definition render.h:647
int * modellightmapoffsets
Definition render.h:660
const r_meshbuffer_t * modellightmapcolor4f_vertexbuffer
Definition render.h:640
int modelelement3s_bufferoffset
Definition render.h:659
int batchnormal3f_bufferoffset
Definition render.h:689
unsigned char * batchskeletalindex4ub
Definition render.h:699
const r_meshbuffer_t * batchlightmapcolor4f_vertexbuffer
Definition render.h:691
float * modeltvector3f
Definition render.h:633
const r_meshbuffer_t * modeltexcoordlightmap2f_vertexbuffer
Definition render.h:646
const r_meshbuffer_t * batchsvector3f_vertexbuffer
Definition render.h:682
qbool modelgeneratedvertex
Definition render.h:616
float fogmasktabledistmultiplier
Definition render.h:746
float * modeltexcoordtexture2f
Definition render.h:642
int modellightmapcolor4f_bufferoffset
Definition render.h:641
const r_meshbuffer_t * batchtvector3f_vertexbuffer
Definition render.h:685
int batchlightmapcolor4f_bufferoffset
Definition render.h:692
const r_meshbuffer_t * entityskeletaltransform3x4buffer
Definition render.h:624
unsigned char * modelskeletalweight4ub
Definition render.h:651
const r_meshbuffer_t * modelvertex3f_vertexbuffer
Definition render.h:628
const r_meshbuffer_t * modelnormal3f_vertexbuffer
Definition render.h:637
float * modelsvector3f
Definition render.h:630
int modelnormal3f_bufferoffset
Definition render.h:638
int entityskeletaltransform3x4size
Definition render.h:626
const r_meshbuffer_t * modelelement3s_indexbuffer
Definition render.h:658
int batchtvector3f_bufferoffset
Definition render.h:686
int batchfirsttriangle
Definition render.h:676
int entityskeletaltransform3x4offset
Definition render.h:625
const r_meshbuffer_t * modeltvector3f_vertexbuffer
Definition render.h:634
const r_meshbuffer_t * batchtexcoordtexture2f_vertexbuffer
Definition render.h:694
int modelskeletalindex4ub_bufferoffset
Definition render.h:650
const r_meshbuffer_t * batchskeletalweight4ub_vertexbuffer
Definition render.h:703
int modelnumvertices
Definition render.h:661
int entityskeletalnumtransforms
Definition render.h:622
const r_meshbuffer_t * batchelement3i_indexbuffer
Definition render.h:706
float matrixscale
Definition render.h:727
int modelvertex3f_bufferoffset
Definition render.h:629
frameblend_t frameblend[MAX_FRAMEBLENDS]
Definition render.h:730
const r_meshbuffer_t * batchnormal3f_vertexbuffer
Definition render.h:688
int modeltexcoordtexture2f_bufferoffset
Definition render.h:644
const r_meshbuffer_t * modelskeletalindex4ub_vertexbuffer
Definition render.h:649
unsigned char * batchskeletalweight4ub
Definition render.h:702
const r_meshbuffer_t * modelelement3i_indexbuffer
Definition render.h:655
const r_meshbuffer_t * modelsvector3f_vertexbuffer
Definition render.h:631
const r_meshbuffer_t * modelskeletalweight4ub_vertexbuffer
Definition render.h:652
int batchsvector3f_bufferoffset
Definition render.h:683
skeleton_t * skeleton
Definition render.h:731
int batchtexcoordtexture2f_bufferoffset
Definition render.h:695
const r_meshbuffer_t * batchelement3s_indexbuffer
Definition render.h:709
const r_meshbuffer_t * batchskeletalindex4ub_vertexbuffer
Definition render.h:700
qbool batchgeneratedvertex
Definition render.h:670
const r_meshbuffer_t * modeltexcoordtexture2f_vertexbuffer
Definition render.h:643

Referenced by R_DrawCorona(), R_DrawModelDecals_Entity(), R_DrawNoModel_TransparentCallback(), R_Model_Sprite_Draw_TransparentCallback(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLightSprite_TransparentCallback(), R_SkyBox(), and R_SkySphere().

◆ RSurf_ActiveModelEntity()

void RSurf_ActiveModelEntity ( const entity_render_t ent,
qbool  wantnormals,
qbool  wanttangents,
qbool  prepass 
)

Definition at line 6957 of file gl_rmain.c.

6958{
6959 model_t *model = ent->model;
6960 //if (rsurface.entity == ent && (!model->surfmesh.isanimated || (!wantnormals && !wanttangents)))
6961 // return;
6963 rsurface.skeleton = ent->skeleton;
6966 rsurface.ent_qwskin = (ent->entitynumber <= cl.maxclients && ent->entitynumber >= 1 && cls.protocol == PROTOCOL_QUAKEWORLD && cl.scores[ent->entitynumber - 1].qw_skin[0] && !strcmp(ent->model->name, "progs/player.mdl")) ? (ent->entitynumber - 1) : -1;
6967 rsurface.ent_flags = ent->flags;
6971 rsurface.matrix = ent->matrix;
6982 memcpy(rsurface.frameblend, ent->frameblend, sizeof(ent->frameblend));
6986 if (ent->model->brush.submodel && !prepass)
6987 {
6990 }
6991 // if the animcache code decided it should use the shader path, skip the deform step
6998 {
6999 if (ent->animcache_vertex3f)
7000 {
7008 rsurface.modelsvector3f = wanttangents ? ent->animcache_svector3f : NULL;
7011 rsurface.modeltvector3f = wanttangents ? ent->animcache_tvector3f : NULL;
7014 rsurface.modelnormal3f = wantnormals ? ent->animcache_normal3f : NULL;
7017 }
7018 else if (wanttangents)
7019 {
7024 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7025 rsurface.modelsvector3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7026 rsurface.modeltvector3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7027 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7039 }
7040 else if (wantnormals)
7041 {
7046 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7049 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7061 }
7062 else
7063 {
7068 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7083 }
7085 }
7086 else
7087 {
7089 {
7094 }
7095 else
7096 {
7101 }
7115 }
7180}
@ PROTOCOL_QUAKEWORLD
quakeworld protocol
Definition common.h:145
@ r_stat_batch_entityanimate_count
Definition r_stats.h:151
@ r_stat_batch_entitycache_triangles
Definition r_stats.h:150
@ r_stat_batch_entityskeletal_vertices
Definition r_stats.h:157
@ r_stat_batch_entitystatic_surfaces
Definition r_stats.h:160
@ r_stat_batch_entitycache_vertices
Definition r_stats.h:149
@ r_stat_batch_entitycache_surfaces
Definition r_stats.h:148
@ r_stat_batch_entityanimate_surfaces
Definition r_stats.h:152
@ r_stat_batch_entitystatic_triangles
Definition r_stats.h:162
@ r_stat_batch_entitystatic_count
Definition r_stats.h:159
@ r_stat_batch_entityskeletal_surfaces
Definition r_stats.h:156
@ r_stat_batch_entitystatic_vertices
Definition r_stats.h:161
@ r_stat_batch_entityanimate_vertices
Definition r_stats.h:153
@ r_stat_batch_entitycache_count
Definition r_stats.h:147
@ r_stat_batch_entityskeletal_triangles
Definition r_stats.h:158
@ r_stat_batch_entityskeletal_count
Definition r_stats.h:155
@ r_stat_batch_entityanimate_triangles
Definition r_stats.h:154
protocolversion_t protocol
Definition client.h:618
vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT]
Definition client.h:446
qbool lit
r_meshbuffer_t * data_svector3f_vertexbuffer
int data_normal3f_bufferoffset
int data_element3s_bufferoffset
int data_skeletalweight4ub_bufferoffset
r_meshbuffer_t * data_lightmapcolor4f_vertexbuffer
r_meshbuffer_t * data_normal3f_vertexbuffer
int data_element3i_bufferoffset
int data_texcoordlightmap2f_bufferoffset
int data_skeletalindex4ub_bufferoffset
int data_svector3f_bufferoffset
float * data_lightmapcolor4f
unsigned char * data_skeletalweight4ub
float * data_svector3f
unsigned short * data_element3s
r_meshbuffer_t * data_texcoordtexture2f_vertexbuffer
r_meshbuffer_t * data_skeletalindex4ub_vertexbuffer
r_meshbuffer_t * data_tvector3f_vertexbuffer
r_meshbuffer_t * data_element3i_indexbuffer
float * data_tvector3f
int * data_lightmapoffsets
int data_texcoordtexture2f_bufferoffset
int num_triangles
int data_tvector3f_bufferoffset
r_meshbuffer_t * data_texcoordlightmap2f_vertexbuffer
r_meshbuffer_t * data_skeletalweight4ub_vertexbuffer
int data_vertex3f_bufferoffset
int data_lightmapcolor4f_bufferoffset
float * data_texcoordtexture2f
r_meshbuffer_t * data_element3s_indexbuffer
float * data_normal3f
float * data_texcoordlightmap2f
r_meshbuffer_t * data_vertex3f_vertexbuffer

Referenced by R_DecalSystem_SplatEntity(), R_DrawBBoxMesh(), R_DrawModelDecals_Entity(), R_DrawModelSurfaces(), R_DrawParticle_TransparentCallback(), R_DrawSurface_TransparentCallback(), R_Mod_DrawAddWaterPlanes(), R_Mod_GetLightInfo(), R_Shadow_DrawCoronas(), R_Shadow_DrawEntityShadow(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), and R_Shadow_SetupEntityLight().

◆ RSurf_DrawBatch()

void RSurf_DrawBatch ( void  )

Definition at line 8513 of file gl_rmain.c.

8514{
8515 // sometimes a zero triangle surface (usually a degenerate patch) makes it
8516 // through the pipeline, killing it earlier in the pipeline would have
8517 // per-surface overhead rather than per-batch overhead, so it's best to
8518 // reject it here, before it hits glDraw.
8519 if (rsurface.batchnumtriangles == 0)
8520 return;
8521#if 0
8522 // batch debugging code
8524 {
8525 int i;
8526 int j;
8527 int c;
8528 const int *e;
8530 for (i = 0;i < rsurface.batchnumtriangles*3;i++)
8531 {
8532 c = e[i];
8533 for (j = 0;j < rsurface.entity->model->num_surfaces;j++)
8534 {
8536 {
8538 Sys_Error("RSurf_DrawBatch: index %i uses different texture (%s) than surface %i which it belongs to (which uses %s)\n", c, rsurface.texture->name, j, rsurface.modelsurfaces[j].texture->name);
8539 break;
8540 }
8541 }
8542 }
8543 }
8544#endif
8546 {
8547 // issue multiple draws rather than copying index data
8548 int numsurfaces = rsurface.batchmultidrawnumsurfaces;
8549 const msurface_t **surfacelist = rsurface.batchmultidrawsurfacelist;
8550 int i, j, k, firstvertex, endvertex, firsttriangle, endtriangle;
8551 for (i = 0;i < numsurfaces;)
8552 {
8553 // combine consecutive surfaces as one draw
8554 for (k = i, j = i + 1;j < numsurfaces;k = j, j++)
8555 if (surfacelist[j] != surfacelist[k] + 1)
8556 break;
8557 firstvertex = surfacelist[i]->num_firstvertex;
8558 endvertex = surfacelist[k]->num_firstvertex + surfacelist[k]->num_vertices;
8559 firsttriangle = surfacelist[i]->num_firsttriangle;
8560 endtriangle = surfacelist[k]->num_firsttriangle + surfacelist[k]->num_triangles;
8562 i = j;
8563 }
8564 }
8565 else
8566 {
8567 // there is only one consecutive run of index data (may have been combined)
8569 }
8570}
int num_firsttriangle
int num_firstvertex
const msurface_t ** batchmultidrawsurfacelist
Definition render.h:673
int batchmultidrawnumsurfaces
Definition render.h:672
qbool batchmultidraw
Definition render.h:671
char name[64]

Referenced by R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_GL20(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Mod_DrawShadowMap(), R_Shadow_RenderLighting_Light_GLSL(), and R_Shadow_RenderLighting_VisibleLighting().

◆ RSurf_FindWaterPlaneForSurface()

static int RSurf_FindWaterPlaneForSurface ( const msurface_t surface)
static

Definition at line 8572 of file gl_rmain.c.

8573{
8574 // pick the closest matching water plane
8575 int planeindex, vertexindex, bestplaneindex = -1;
8576 float d, bestd;
8577 vec3_t vert;
8578 const float *v;
8580 qbool prepared = false;
8581 bestd = 0;
8582 for (planeindex = 0, p = r_fb.water.waterplanes;planeindex < r_fb.water.numwaterplanes;planeindex++, p++)
8583 {
8585 continue;
8586 d = 0;
8587 if(!prepared)
8588 {
8590 prepared = true;
8591 if(rsurface.batchnumvertices == 0)
8592 break;
8593 }
8595 {
8597 d += fabs(PlaneDiff(vert, &p->plane));
8598 }
8599 if (bestd > d || bestplaneindex < 0)
8600 {
8601 bestd = d;
8602 bestplaneindex = planeindex;
8603 }
8604 }
8605 return bestplaneindex;
8606 // NOTE: this MAY return a totally unrelated water plane; we can ignore
8607 // this situation though, as it might be better to render single larger
8608 // batches with useless stuff (backface culled for example) than to
8609 // render multiple smaller batches
8610}

Referenced by R_DrawTextureSurfaceList_GL20().

◆ RSurf_FogPoint()

float RSurf_FogPoint ( const float v)

Definition at line 7344 of file gl_rmain.c.

7345{
7346 // this code is identical to the USEFOGINSIDE/USEFOGOUTSIDE code in the shader
7350 float fogfrac;
7351 unsigned int fogmasktableindex;
7354 else
7358}
#define VectorDistance(a, b)
Definition mathlib.h:107
uniform highp float FogHeightFade
float fogfrac
vec3 float FogPlaneVertexDist
uniform highp float FogPlaneViewDist

◆ RSurf_FogVertex()

◆ RSurf_PrepareVerticesForBatch()

void RSurf_PrepareVerticesForBatch ( int  batchneed,
int  texturenumsurfaces,
const msurface_t **  texturesurfacelist 
)

Definition at line 7424 of file gl_rmain.c.

7425{
7426 int deformindex;
7427 int firsttriangle;
7428 int numtriangles;
7429 int firstvertex;
7430 int endvertex;
7431 int numvertices;
7435 int surfaceendvertex;
7438 int batchnumvertices;
7439 int batchnumtriangles;
7440 int i, j;
7441 qbool gaps;
7443 float amplitude;
7444 float animpos;
7445 float center[3], forward[3], right[3], up[3], v[3], newforward[3], newright[3], newup[3];
7446 float waveparms[4];
7447 unsigned char *ub;
7448 q3shaderinfo_deform_t *deform;
7449 const msurface_t *surface, *firstsurface;
7450 if (!texturenumsurfaces)
7451 return;
7452 // find vertex range of this surface batch
7453 gaps = false;
7454 firstsurface = texturesurfacelist[0];
7455 firsttriangle = firstsurface->num_firsttriangle;
7456 batchnumvertices = 0;
7457 batchnumtriangles = 0;
7458 firstvertex = endvertex = firstsurface->num_firstvertex;
7459 for (i = 0;i < texturenumsurfaces;i++)
7460 {
7462 if (surface != firstsurface + i)
7463 gaps = true;
7464 surfacefirstvertex = surface->num_firstvertex;
7466 surfacenumvertices = surface->num_vertices;
7467 surfacenumtriangles = surface->num_triangles;
7468 if (firstvertex > surfacefirstvertex)
7469 firstvertex = surfacefirstvertex;
7472 batchnumvertices += surfacenumvertices;
7473 batchnumtriangles += surfacenumtriangles;
7474 }
7475
7477 if (gaps)
7480 r_refdef.stats[r_stat_batch_vertices] += batchnumvertices;
7481 r_refdef.stats[r_stat_batch_triangles] += batchnumtriangles;
7482
7483 // we now know the vertex range used, and if there are any gaps in it
7484 rsurface.batchfirstvertex = firstvertex;
7485 rsurface.batchnumvertices = endvertex - firstvertex;
7487 rsurface.batchnumtriangles = batchnumtriangles;
7488
7489 // check if any dynamic vertex processing must occur
7490 dynamicvertex = false;
7491
7492 // we must use vertexbuffers for rendering, we can upload vertex buffers
7493 // easily enough but if the basevertex is non-zero it becomes more
7494 // difficult, so force dynamicvertex path in that case - it's suboptimal
7495 // but the most optimal case is to have the geometry sources provide their
7496 // own anyway.
7497 if (!rsurface.modelvertex3f_vertexbuffer && firstvertex != 0)
7498 dynamicvertex = true;
7499
7500 // a cvar to force the dynamic vertex path to be taken, for debugging
7502 {
7503 if (!dynamicvertex)
7504 {
7509 }
7510 dynamicvertex = true;
7511 }
7512
7513 // if there is a chance of animated vertex colors, it's a dynamic batch
7514 if ((batchneed & BATCHNEED_ARRAY_VERTEXCOLOR) && texturesurfacelist[0]->lightmapinfo)
7515 {
7516 if (!dynamicvertex)
7517 {
7522 }
7523 dynamicvertex = true;
7524 }
7525
7526 for (deformindex = 0, deform = rsurface.texture->deforms;deformindex < Q3MAXDEFORMS && deform->deform && r_deformvertexes.integer;deformindex++, deform++)
7527 {
7528 switch (deform->deform)
7529 {
7530 default:
7532 case Q3DEFORM_TEXT0:
7533 case Q3DEFORM_TEXT1:
7534 case Q3DEFORM_TEXT2:
7535 case Q3DEFORM_TEXT3:
7536 case Q3DEFORM_TEXT4:
7537 case Q3DEFORM_TEXT5:
7538 case Q3DEFORM_TEXT6:
7539 case Q3DEFORM_TEXT7:
7540 case Q3DEFORM_NONE:
7541 break;
7543 if (!dynamicvertex)
7544 {
7549 }
7550 dynamicvertex = true;
7552 break;
7554 if (!dynamicvertex)
7555 {
7560 }
7561 dynamicvertex = true;
7563 break;
7564 case Q3DEFORM_NORMAL:
7565 if (!dynamicvertex)
7566 {
7571 }
7572 dynamicvertex = true;
7574 break;
7575 case Q3DEFORM_WAVE:
7576 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
7577 break; // if wavefunc is a nop, ignore this transform
7578 if (!dynamicvertex)
7579 {
7584 }
7585 dynamicvertex = true;
7587 break;
7588 case Q3DEFORM_BULGE:
7589 if (!dynamicvertex)
7590 {
7595 }
7596 dynamicvertex = true;
7598 break;
7599 case Q3DEFORM_MOVE:
7600 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
7601 break; // if wavefunc is a nop, ignore this transform
7602 if (!dynamicvertex)
7603 {
7608 }
7609 dynamicvertex = true;
7611 break;
7612 }
7613 }
7615 {
7617 {
7618 default:
7619 case Q3TCGEN_TEXTURE:
7620 break;
7621 case Q3TCGEN_LIGHTMAP:
7622 if (!dynamicvertex)
7623 {
7628 }
7629 dynamicvertex = true;
7631 break;
7632 case Q3TCGEN_VECTOR:
7633 if (!dynamicvertex)
7634 {
7639 }
7640 dynamicvertex = true;
7642 break;
7644 if (!dynamicvertex)
7645 {
7650 }
7651 dynamicvertex = true;
7653 break;
7654 }
7656 {
7657 if (!dynamicvertex)
7658 {
7663 }
7664 dynamicvertex = true;
7666 }
7667 }
7668
7669 // the caller can specify BATCHNEED_NOGAPS to force a batch with
7670 // firstvertex = 0 and endvertex = numvertices (no gaps, no firstvertex),
7671 // we ensure this by treating the vertex batch as dynamic...
7672 if ((batchneed & BATCHNEED_ALWAYSCOPY) || ((batchneed & BATCHNEED_NOGAPS) && (gaps || firstvertex > 0)))
7673 {
7674 if (!dynamicvertex)
7675 {
7680 }
7681 dynamicvertex = true;
7682 }
7683
7684 // if we're going to have to apply the skeletal transform manually, we need to batch the skeletal data
7687
7726
7727 // if any dynamic vertex processing has to occur in software, we copy the
7728 // entire surface list together before processing to rebase the vertices
7729 // to start at 0 (otherwise we waste a lot of room in a vertex buffer).
7730 //
7731 // if any gaps exist and we do not have a static vertex buffer, we have to
7732 // copy the surface list together to avoid wasting upload bandwidth on the
7733 // vertices in the gaps.
7734 //
7735 // if gaps exist and we have a static vertex buffer, we can choose whether
7736 // to combine the index buffer ranges into one dynamic index buffer or
7737 // simply issue multiple glDrawElements calls (BATCHNEED_ALLOWMULTIDRAW).
7738 //
7739 // in many cases the batch is reduced to one draw call.
7740
7741 rsurface.batchmultidraw = false;
7744
7745 if (!dynamicvertex)
7746 {
7747 // static vertex data, just set pointers...
7749 // if there are gaps, we want to build a combined index buffer,
7750 // otherwise use the original static buffer with an appropriate offset
7751 if (gaps)
7752 {
7758 {
7759 rsurface.batchmultidraw = true;
7762 return;
7763 }
7764 // build a new triangle elements array for this batch
7765 rsurface.batchelement3i = (int *)R_FrameData_Alloc(batchnumtriangles * sizeof(int[3]));
7767 numtriangles = 0;
7768 for (i = 0;i < texturenumsurfaces;i++)
7769 {
7770 surfacefirsttriangle = texturesurfacelist[i]->num_firsttriangle;
7771 surfacenumtriangles = texturesurfacelist[i]->num_triangles;
7773 numtriangles += surfacenumtriangles;
7774 }
7780 if (endvertex <= 65536)
7781 {
7782 // make a 16bit (unsigned short) index array if possible
7783 rsurface.batchelement3s = (unsigned short *)R_FrameData_Alloc(batchnumtriangles * sizeof(unsigned short[3]));
7784 for (i = 0;i < numtriangles*3;i++)
7786 }
7787 }
7788 else
7789 {
7792 r_refdef.stats[r_stat_batch_fast_vertices] += batchnumvertices;
7793 r_refdef.stats[r_stat_batch_fast_triangles] += batchnumtriangles;
7794 }
7795 return;
7796 }
7797
7798 // something needs software processing, do it for real...
7799 // we only directly handle separate array data in this case and then
7800 // generate interleaved data if needed...
7804 r_refdef.stats[r_stat_batch_dynamic_vertices] += batchnumvertices;
7805 r_refdef.stats[r_stat_batch_dynamic_triangles] += batchnumtriangles;
7806
7807 // now copy the vertex data into a combined array and make an index array
7808 // (this is what Quake3 does all the time)
7809 // we also apply any skeletal animation here that would have been done in
7810 // the vertex shader, because most of the dynamic vertex animation cases
7811 // need actual vertex positions and normals
7812 //if (dynamicvertex)
7813 {
7841 rsurface.batchelement3i = (int *)R_FrameData_Alloc(batchnumtriangles * sizeof(int[3]));
7850 // we'll only be setting up certain arrays as needed
7852 rsurface.batchvertex3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7854 rsurface.batchnormal3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7856 {
7857 rsurface.batchsvector3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7858 rsurface.batchtvector3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7859 }
7861 rsurface.batchlightmapcolor4f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[4]));
7863 rsurface.batchtexcoordtexture2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
7865 rsurface.batchtexcoordlightmap2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
7867 {
7868 rsurface.batchskeletalindex4ub = (unsigned char *)R_FrameData_Alloc(batchnumvertices * sizeof(unsigned char[4]));
7869 rsurface.batchskeletalweight4ub = (unsigned char *)R_FrameData_Alloc(batchnumvertices * sizeof(unsigned char[4]));
7870 }
7871 numvertices = 0;
7872 numtriangles = 0;
7873 for (i = 0;i < texturenumsurfaces;i++)
7874 {
7875 surfacefirstvertex = texturesurfacelist[i]->num_firstvertex;
7876 surfacenumvertices = texturesurfacelist[i]->num_vertices;
7877 surfacefirsttriangle = texturesurfacelist[i]->num_firsttriangle;
7878 surfacenumtriangles = texturesurfacelist[i]->num_triangles;
7879 // copy only the data requested
7881 {
7883 {
7886 else
7887 memset(rsurface.batchvertex3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7888 }
7890 {
7893 else
7894 memset(rsurface.batchnormal3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7895 }
7897 {
7899 {
7902 }
7903 else
7904 {
7905 memset(rsurface.batchsvector3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7906 memset(rsurface.batchtvector3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7907 }
7908 }
7910 {
7913 else
7914 memset(rsurface.batchlightmapcolor4f + 4*numvertices, 0, surfacenumvertices * sizeof(float[4]));
7915 }
7917 {
7920 else
7921 memset(rsurface.batchtexcoordtexture2f + 2*numvertices, 0, surfacenumvertices * sizeof(float[2]));
7922 }
7924 {
7927 else
7928 memset(rsurface.batchtexcoordlightmap2f + 2*numvertices, 0, surfacenumvertices * sizeof(float[2]));
7929 }
7931 {
7933 {
7936 }
7937 else
7938 {
7939 memset(rsurface.batchskeletalindex4ub + 4*numvertices, 0, surfacenumvertices * sizeof(unsigned char[4]));
7940 memset(rsurface.batchskeletalweight4ub + 4*numvertices, 0, surfacenumvertices * sizeof(unsigned char[4]));
7941 ub = rsurface.batchskeletalweight4ub + 4*numvertices;
7942 for (j = 0;j < surfacenumvertices;j++)
7943 ub[j*4] = 255;
7944 }
7945 }
7946 }
7948 numvertices += surfacenumvertices;
7949 numtriangles += surfacenumtriangles;
7950 }
7951
7952 // generate a 16bit index array as well if possible
7953 // (in general, dynamic batches fit)
7954 if (numvertices <= 65536)
7955 {
7956 rsurface.batchelement3s = (unsigned short *)R_FrameData_Alloc(batchnumtriangles * sizeof(unsigned short[3]));
7957 for (i = 0;i < numtriangles*3;i++)
7959 }
7960
7961 // since we've copied everything, the batch now starts at 0
7963 rsurface.batchnumvertices = batchnumvertices;
7965 rsurface.batchnumtriangles = batchnumtriangles;
7966 }
7967
7968 // apply skeletal animation that would have been done in the vertex shader
7970 {
7971 const unsigned char *si;
7972 const unsigned char *sw;
7973 const float *t[4];
7974 const float *b = rsurface.batchskeletaltransform3x4;
7975 float *vp, *vs, *vt, *vn;
7976 float w[4];
7977 float m[3][4], n[3][4];
7978 float tp[3], ts[3], tt[3], tn[3];
7989 memset(m[0], 0, sizeof(m));
7990 memset(n[0], 0, sizeof(n));
7991 for (i = 0;i < batchnumvertices;i++)
7992 {
7993 t[0] = b + si[0]*12;
7994 if (sw[0] == 255)
7995 {
7996 // common case - only one matrix
7997 m[0][0] = t[0][ 0];
7998 m[0][1] = t[0][ 1];
7999 m[0][2] = t[0][ 2];
8000 m[0][3] = t[0][ 3];
8001 m[1][0] = t[0][ 4];
8002 m[1][1] = t[0][ 5];
8003 m[1][2] = t[0][ 6];
8004 m[1][3] = t[0][ 7];
8005 m[2][0] = t[0][ 8];
8006 m[2][1] = t[0][ 9];
8007 m[2][2] = t[0][10];
8008 m[2][3] = t[0][11];
8009 }
8010 else if (sw[2] + sw[3])
8011 {
8012 // blend 4 matrices
8013 t[1] = b + si[1]*12;
8014 t[2] = b + si[2]*12;
8015 t[3] = b + si[3]*12;
8016 w[0] = sw[0] * (1.0f / 255.0f);
8017 w[1] = sw[1] * (1.0f / 255.0f);
8018 w[2] = sw[2] * (1.0f / 255.0f);
8019 w[3] = sw[3] * (1.0f / 255.0f);
8020 // blend the matrices
8021 m[0][0] = t[0][ 0] * w[0] + t[1][ 0] * w[1] + t[2][ 0] * w[2] + t[3][ 0] * w[3];
8022 m[0][1] = t[0][ 1] * w[0] + t[1][ 1] * w[1] + t[2][ 1] * w[2] + t[3][ 1] * w[3];
8023 m[0][2] = t[0][ 2] * w[0] + t[1][ 2] * w[1] + t[2][ 2] * w[2] + t[3][ 2] * w[3];
8024 m[0][3] = t[0][ 3] * w[0] + t[1][ 3] * w[1] + t[2][ 3] * w[2] + t[3][ 3] * w[3];
8025 m[1][0] = t[0][ 4] * w[0] + t[1][ 4] * w[1] + t[2][ 4] * w[2] + t[3][ 4] * w[3];
8026 m[1][1] = t[0][ 5] * w[0] + t[1][ 5] * w[1] + t[2][ 5] * w[2] + t[3][ 5] * w[3];
8027 m[1][2] = t[0][ 6] * w[0] + t[1][ 6] * w[1] + t[2][ 6] * w[2] + t[3][ 6] * w[3];
8028 m[1][3] = t[0][ 7] * w[0] + t[1][ 7] * w[1] + t[2][ 7] * w[2] + t[3][ 7] * w[3];
8029 m[2][0] = t[0][ 8] * w[0] + t[1][ 8] * w[1] + t[2][ 8] * w[2] + t[3][ 8] * w[3];
8030 m[2][1] = t[0][ 9] * w[0] + t[1][ 9] * w[1] + t[2][ 9] * w[2] + t[3][ 9] * w[3];
8031 m[2][2] = t[0][10] * w[0] + t[1][10] * w[1] + t[2][10] * w[2] + t[3][10] * w[3];
8032 m[2][3] = t[0][11] * w[0] + t[1][11] * w[1] + t[2][11] * w[2] + t[3][11] * w[3];
8033 }
8034 else
8035 {
8036 // blend 2 matrices
8037 t[1] = b + si[1]*12;
8038 w[0] = sw[0] * (1.0f / 255.0f);
8039 w[1] = sw[1] * (1.0f / 255.0f);
8040 // blend the matrices
8041 m[0][0] = t[0][ 0] * w[0] + t[1][ 0] * w[1];
8042 m[0][1] = t[0][ 1] * w[0] + t[1][ 1] * w[1];
8043 m[0][2] = t[0][ 2] * w[0] + t[1][ 2] * w[1];
8044 m[0][3] = t[0][ 3] * w[0] + t[1][ 3] * w[1];
8045 m[1][0] = t[0][ 4] * w[0] + t[1][ 4] * w[1];
8046 m[1][1] = t[0][ 5] * w[0] + t[1][ 5] * w[1];
8047 m[1][2] = t[0][ 6] * w[0] + t[1][ 6] * w[1];
8048 m[1][3] = t[0][ 7] * w[0] + t[1][ 7] * w[1];
8049 m[2][0] = t[0][ 8] * w[0] + t[1][ 8] * w[1];
8050 m[2][1] = t[0][ 9] * w[0] + t[1][ 9] * w[1];
8051 m[2][2] = t[0][10] * w[0] + t[1][10] * w[1];
8052 m[2][3] = t[0][11] * w[0] + t[1][11] * w[1];
8053 }
8054 si += 4;
8055 sw += 4;
8056 // modify the vertex
8057 VectorCopy(vp, tp);
8058 vp[0] = tp[0] * m[0][0] + tp[1] * m[0][1] + tp[2] * m[0][2] + m[0][3];
8059 vp[1] = tp[0] * m[1][0] + tp[1] * m[1][1] + tp[2] * m[1][2] + m[1][3];
8060 vp[2] = tp[0] * m[2][0] + tp[1] * m[2][1] + tp[2] * m[2][2] + m[2][3];
8061 vp += 3;
8062 if (vn)
8063 {
8064 // the normal transformation matrix is a set of cross products...
8065 CrossProduct(m[1], m[2], n[0]);
8066 CrossProduct(m[2], m[0], n[1]);
8067 CrossProduct(m[0], m[1], n[2]); // is actually transpose(inverse(m)) * det(m)
8068 VectorCopy(vn, tn);
8069 vn[0] = tn[0] * n[0][0] + tn[1] * n[0][1] + tn[2] * n[0][2];
8070 vn[1] = tn[0] * n[1][0] + tn[1] * n[1][1] + tn[2] * n[1][2];
8071 vn[2] = tn[0] * n[2][0] + tn[1] * n[2][1] + tn[2] * n[2][2];
8072 VectorNormalize(vn);
8073 vn += 3;
8074 if (vs)
8075 {
8076 VectorCopy(vs, ts);
8077 vs[0] = ts[0] * n[0][0] + ts[1] * n[0][1] + ts[2] * n[0][2];
8078 vs[1] = ts[0] * n[1][0] + ts[1] * n[1][1] + ts[2] * n[1][2];
8079 vs[2] = ts[0] * n[2][0] + ts[1] * n[2][1] + ts[2] * n[2][2];
8081 vs += 3;
8082 VectorCopy(vt, tt);
8083 vt[0] = tt[0] * n[0][0] + tt[1] * n[0][1] + tt[2] * n[0][2];
8084 vt[1] = tt[0] * n[1][0] + tt[1] * n[1][1] + tt[2] * n[1][2];
8085 vt[2] = tt[0] * n[2][0] + tt[1] * n[2][1] + tt[2] * n[2][2];
8086 VectorNormalize(vt);
8087 vt += 3;
8088 }
8089 }
8090 }
8093 }
8094
8095 // q1bsp surfaces rendered in vertex color mode have to have colors
8096 // calculated based on lightstyles
8097 if ((batchneed & BATCHNEED_ARRAY_VERTEXCOLOR) && texturesurfacelist[0]->lightmapinfo)
8098 {
8099 // generate color arrays for the surfaces in this list
8100 int c[4];
8101 int scale;
8102 int size3;
8103 const int *offsets;
8104 const unsigned char *lm;
8105 rsurface.batchlightmapcolor4f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[4]));
8108 numvertices = 0;
8109 for (i = 0;i < texturenumsurfaces;i++)
8110 {
8112 offsets = rsurface.modellightmapoffsets + surface->num_firstvertex;
8113 surfacenumvertices = surface->num_vertices;
8114 if (surface->lightmapinfo->samples)
8115 {
8116 for (j = 0;j < surfacenumvertices;j++)
8117 {
8118 lm = surface->lightmapinfo->samples + offsets[j];
8119 scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[0]];
8120 VectorScale(lm, scale, c);
8121 if (surface->lightmapinfo->styles[1] != 255)
8122 {
8123 size3 = ((surface->lightmapinfo->extents[0]>>4)+1)*((surface->lightmapinfo->extents[1]>>4)+1)*3;
8124 lm += size3;
8125 scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[1]];
8126 VectorMA(c, scale, lm, c);
8127 if (surface->lightmapinfo->styles[2] != 255)
8128 {
8129 lm += size3;
8130 scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[2]];
8131 VectorMA(c, scale, lm, c);
8132 if (surface->lightmapinfo->styles[3] != 255)
8133 {
8134 lm += size3;
8135 scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[3]];
8136 VectorMA(c, scale, lm, c);
8137 }
8138 }
8139 }
8140 c[0] >>= 7;
8141 c[1] >>= 7;
8142 c[2] >>= 7;
8143 Vector4Set(rsurface.batchlightmapcolor4f + 4*numvertices, min(c[0], 255) * (1.0f / 255.0f), min(c[1], 255) * (1.0f / 255.0f), min(c[2], 255) * (1.0f / 255.0f), 1);
8144 numvertices++;
8145 }
8146 }
8147 else
8148 {
8149 for (j = 0;j < surfacenumvertices;j++)
8150 {
8151 Vector4Set(rsurface.batchlightmapcolor4f + 4*numvertices, 0, 0, 0, 1);
8152 numvertices++;
8153 }
8154 }
8155 }
8156 }
8157
8158 // if vertices are deformed (sprite flares and things in maps, possibly
8159 // water waves, bulges and other deformations), modify the copied vertices
8160 // in place
8161 for (deformindex = 0, deform = rsurface.texture->deforms;deformindex < Q3MAXDEFORMS && deform->deform && r_deformvertexes.integer;deformindex++, deform++)
8162 {
8163 float scale;
8164 switch (deform->deform)
8165 {
8166 default:
8168 case Q3DEFORM_TEXT0:
8169 case Q3DEFORM_TEXT1:
8170 case Q3DEFORM_TEXT2:
8171 case Q3DEFORM_TEXT3:
8172 case Q3DEFORM_TEXT4:
8173 case Q3DEFORM_TEXT5:
8174 case Q3DEFORM_TEXT6:
8175 case Q3DEFORM_TEXT7:
8176 case Q3DEFORM_NONE:
8177 break;
8185// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8186// rsurface.batchvertex3f_vertexbuffer = NULL;
8187// rsurface.batchvertex3f_bufferoffset = 0;
8188// rsurface.batchsvector3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchsvector3f);
8189// rsurface.batchsvector3f_vertexbuffer = NULL;
8190// rsurface.batchsvector3f_bufferoffset = 0;
8191// rsurface.batchtvector3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchtvector3f);
8192// rsurface.batchtvector3f_vertexbuffer = NULL;
8193// rsurface.batchtvector3f_bufferoffset = 0;
8194// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8195// rsurface.batchnormal3f_vertexbuffer = NULL;
8196// rsurface.batchnormal3f_bufferoffset = 0;
8197 // sometimes we're on a renderpath that does not use vectors (GL11/GL13/GLES1)
8202 // a single autosprite surface can contain multiple sprites...
8203 for (j = 0;j < batchnumvertices - 3;j += 4)
8204 {
8205 VectorClear(center);
8206 for (i = 0;i < 4;i++)
8207 VectorAdd(center, rsurface.batchvertex3f + 3*(j+i), center);
8208 VectorScale(center, 0.25f, center);
8212 for (i = 0;i < 4;i++)
8213 {
8214 VectorSubtract(rsurface.batchvertex3f + 3*(j+i), center, v);
8216 }
8217 }
8218 // if we get here, BATCHNEED_ARRAY_NORMAL and BATCHNEED_ARRAY_VECTOR are in batchneed, so no need to check
8221 break;
8229// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8230// rsurface.batchvertex3f_vertexbuffer = NULL;
8231// rsurface.batchvertex3f_bufferoffset = 0;
8232 {
8233 const float *v1, *v2;
8234 vec3_t start, end;
8235 float f, l;
8236 struct
8237 {
8238 float length2;
8239 const float *v1;
8240 const float *v2;
8241 }
8242 shortest[2];
8243 memset(shortest, 0, sizeof(shortest));
8244 // a single autosprite surface can contain multiple sprites...
8245 for (j = 0;j < batchnumvertices - 3;j += 4)
8246 {
8247 VectorClear(center);
8248 for (i = 0;i < 4;i++)
8249 VectorAdd(center, rsurface.batchvertex3f + 3*(j+i), center);
8250 VectorScale(center, 0.25f, center);
8251 // find the two shortest edges, then use them to define the
8252 // axis vectors for rotating around the central axis
8253 for (i = 0;i < 6;i++)
8254 {
8255 v1 = rsurface.batchvertex3f + 3*(j+quadedges[i][0]);
8256 v2 = rsurface.batchvertex3f + 3*(j+quadedges[i][1]);
8257 l = VectorDistance2(v1, v2);
8258 // this length bias tries to make sense of square polygons, assuming they are meant to be upright
8259 if (v1[2] != v2[2])
8260 l += (1.0f / 1024.0f);
8261 if (shortest[0].length2 > l || i == 0)
8262 {
8263 shortest[1] = shortest[0];
8264 shortest[0].length2 = l;
8265 shortest[0].v1 = v1;
8266 shortest[0].v2 = v2;
8267 }
8268 else if (shortest[1].length2 > l || i == 1)
8269 {
8270 shortest[1].length2 = l;
8271 shortest[1].v1 = v1;
8272 shortest[1].v2 = v2;
8273 }
8274 }
8275 VectorLerp(shortest[0].v1, 0.5f, shortest[0].v2, start);
8276 VectorLerp(shortest[1].v1, 0.5f, shortest[1].v2, end);
8277 // this calculates the right vector from the shortest edge
8278 // and the up vector from the edge midpoints
8281 VectorSubtract(end, start, up);
8283 // calculate a forward vector to use instead of the original plane normal (this is how we get a new right vector)
8285 //Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.forward, forward);
8291 // rotate the quad around the up axis vector, this is made
8292 // especially easy by the fact we know the quad is flat,
8293 // so we only have to subtract the center position and
8294 // measure distance along the right vector, and then
8295 // multiply that by the newright vector and add back the
8296 // center position
8297 // we also need to subtract the old position to undo the
8298 // displacement from the center, which we do with a
8299 // DotProduct, the subtraction/addition of center is also
8300 // optimized into DotProducts here
8301 l = DotProduct(right, center);
8302 for (i = 0;i < 4;i++)
8303 {
8304 v1 = rsurface.batchvertex3f + 3*(j+i);
8305 f = DotProduct(right, v1) - l;
8307 }
8308 }
8309 }
8310 if(batchneed & (BATCHNEED_ARRAY_NORMAL | BATCHNEED_ARRAY_VECTOR)) // otherwise these can stay NULL
8311 {
8312// rsurface.batchnormal3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8313// rsurface.batchnormal3f_vertexbuffer = NULL;
8314// rsurface.batchnormal3f_bufferoffset = 0;
8316 }
8317 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8318 {
8319// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8320// rsurface.batchsvector3f_vertexbuffer = NULL;
8321// rsurface.batchsvector3f_bufferoffset = 0;
8322// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8323// rsurface.batchtvector3f_vertexbuffer = NULL;
8324// rsurface.batchtvector3f_bufferoffset = 0;
8326 }
8327 break;
8328 case Q3DEFORM_NORMAL:
8329 // deform the normals to make reflections wavey
8330 rsurface.batchnormal3f = (float *)R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8333 for (j = 0;j < batchnumvertices;j++)
8334 {
8335 float vertex[3];
8336 float *normal = rsurface.batchnormal3f + 3*j;
8337 VectorScale(rsurface.batchvertex3f + 3*j, 0.98f, vertex);
8338 normal[0] = rsurface.batchnormal3f[j*3+0] + deform->parms[0] * noise4f( vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8339 normal[1] = rsurface.batchnormal3f[j*3+1] + deform->parms[0] * noise4f( 98 + vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8340 normal[2] = rsurface.batchnormal3f[j*3+2] + deform->parms[0] * noise4f(196 + vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8342 }
8343 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8344 {
8345// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8346// rsurface.batchsvector3f_vertexbuffer = NULL;
8347// rsurface.batchsvector3f_bufferoffset = 0;
8348// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8349// rsurface.batchtvector3f_vertexbuffer = NULL;
8350// rsurface.batchtvector3f_bufferoffset = 0;
8352 }
8353 break;
8354 case Q3DEFORM_WAVE:
8355 // deform vertex array to make wavey water and flags and such
8356 waveparms[0] = deform->waveparms[0];
8357 waveparms[1] = deform->waveparms[1];
8358 waveparms[2] = deform->waveparms[2];
8359 waveparms[3] = deform->waveparms[3];
8360 if(!R_TestQ3WaveFunc(deform->wavefunc, waveparms))
8361 break; // if wavefunc is a nop, don't make a dynamic vertex array
8362 // this is how a divisor of vertex influence on deformation
8363 animpos = deform->parms[0] ? 1.0f / deform->parms[0] : 100.0f;
8364 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, waveparms);
8365// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8366// rsurface.batchvertex3f_vertexbuffer = NULL;
8367// rsurface.batchvertex3f_bufferoffset = 0;
8368// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8369// rsurface.batchnormal3f_vertexbuffer = NULL;
8370// rsurface.batchnormal3f_bufferoffset = 0;
8371 for (j = 0;j < batchnumvertices;j++)
8372 {
8373 // if the wavefunc depends on time, evaluate it per-vertex
8374 if (waveparms[3])
8375 {
8376 waveparms[2] = deform->waveparms[2] + (rsurface.batchvertex3f[j*3+0] + rsurface.batchvertex3f[j*3+1] + rsurface.batchvertex3f[j*3+2]) * animpos;
8377 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, waveparms);
8378 }
8380 }
8381 // if we get here, BATCHNEED_ARRAY_NORMAL is in batchneed, so no need to check
8383 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8384 {
8385// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8386// rsurface.batchsvector3f_vertexbuffer = NULL;
8387// rsurface.batchsvector3f_bufferoffset = 0;
8388// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8389// rsurface.batchtvector3f_vertexbuffer = NULL;
8390// rsurface.batchtvector3f_bufferoffset = 0;
8392 }
8393 break;
8394 case Q3DEFORM_BULGE:
8395 // deform vertex array to make the surface have moving bulges
8396// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8397// rsurface.batchvertex3f_vertexbuffer = NULL;
8398// rsurface.batchvertex3f_bufferoffset = 0;
8399// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8400// rsurface.batchnormal3f_vertexbuffer = NULL;
8401// rsurface.batchnormal3f_bufferoffset = 0;
8402 for (j = 0;j < batchnumvertices;j++)
8403 {
8404 scale = sin(rsurface.batchtexcoordtexture2f[j*2+0] * deform->parms[0] + rsurface.shadertime * deform->parms[2]) * deform->parms[1];
8406 }
8407 // if we get here, BATCHNEED_ARRAY_NORMAL is in batchneed, so no need to check
8409 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8410 {
8411// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8412// rsurface.batchsvector3f_vertexbuffer = NULL;
8413// rsurface.batchsvector3f_bufferoffset = 0;
8414// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8415// rsurface.batchtvector3f_vertexbuffer = NULL;
8416// rsurface.batchtvector3f_bufferoffset = 0;
8418 }
8419 break;
8420 case Q3DEFORM_MOVE:
8421 // deform vertex array
8422 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
8423 break; // if wavefunc is a nop, don't make a dynamic vertex array
8424 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, deform->waveparms);
8425 VectorScale(deform->parms, scale, waveparms);
8426// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8427// rsurface.batchvertex3f_vertexbuffer = NULL;
8428// rsurface.batchvertex3f_bufferoffset = 0;
8429 for (j = 0;j < batchnumvertices;j++)
8431 break;
8432 }
8433 }
8434
8436 {
8437 // generate texcoords based on the chosen texcoord source
8439 {
8440 default:
8441 case Q3TCGEN_TEXTURE:
8442 break;
8443 case Q3TCGEN_LIGHTMAP:
8444 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8445 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8446 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8448 memcpy(rsurface.batchtexcoordtexture2f, rsurface.batchtexcoordlightmap2f, batchnumvertices * sizeof(float[2]));
8449 break;
8450 case Q3TCGEN_VECTOR:
8451 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8452 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8453 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8454 for (j = 0;j < batchnumvertices;j++)
8455 {
8458 }
8459 break;
8461 // make environment reflections using a spheremap
8462 rsurface.batchtexcoordtexture2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8465 for (j = 0;j < batchnumvertices;j++)
8466 {
8467 // identical to Q3A's method, but executed in worldspace so
8468 // carried models can be shiny too
8469
8470 float viewer[3], d, reflected[3], worldreflected[3];
8471
8473 // VectorNormalize(viewer);
8474
8476
8477 reflected[0] = rsurface.batchnormal3f[j*3+0]*2*d - viewer[0];
8478 reflected[1] = rsurface.batchnormal3f[j*3+1]*2*d - viewer[1];
8479 reflected[2] = rsurface.batchnormal3f[j*3+2]*2*d - viewer[2];
8480 // note: this is proportinal to viewer, so we can normalize later
8481
8484
8485 // note: this sphere map only uses world x and z!
8486 // so positive and negative y will LOOK THE SAME.
8487 rsurface.batchtexcoordtexture2f[j*2+0] = 0.5 + 0.5 * worldreflected[1];
8488 rsurface.batchtexcoordtexture2f[j*2+1] = 0.5 - 0.5 * worldreflected[2];
8489 }
8490 break;
8491 }
8492 // the only tcmod that needs software vertex processing is turbulent, so
8493 // check for it here and apply the changes if needed
8494 // and we only support that as the first one
8495 // (handling a mixture of turbulent and other tcmods would be problematic
8496 // without punting it entirely to a software path)
8498 {
8501 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8502 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8503 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8504 for (j = 0;j < batchnumvertices;j++)
8505 {
8506 rsurface.batchtexcoordtexture2f[j*2+0] += amplitude * sin(((rsurface.batchvertex3f[j*3+0] + rsurface.batchvertex3f[j*3+2]) * 1.0 / 1024.0f + animpos) * M_PI * 2);
8507 rsurface.batchtexcoordtexture2f[j*2+1] += amplitude * sin(((rsurface.batchvertex3f[j*3+1] ) * 1.0 / 1024.0f + animpos) * M_PI * 2);
8508 }
8509 }
8510 }
8511}
static vec3_t offsets[NUMOFFSETS]
Definition cl_input.c:838
float noise4f(float x, float y, float z, float w)
static void RSurf_RenumberElements(const int *inelement3i, int *outelement3i, int numelements, int adjust)
Definition gl_rmain.c:7416
static const int quadedges[6][2]
Definition gl_rmain.c:7423
static qbool R_TestQ3WaveFunc(q3wavefunc_t func, const float *parms)
Definition gl_rmain.c:6433
void * R_FrameData_Store(size_t size, void *data)
allocate some temporary memory and copy this data into it
Definition gl_rmain.c:3581
#define VectorReflect(a, r, b, c)
Definition mathlib.h:120
#define VectorMAMAMAM(scale1, b1, scale2, b2, scale3, b3, scale4, b4, c)
Definition mathlib.h:117
#define VectorClear(a)
Definition mathlib.h:96
#define Q3MAXDEFORMS
Definition r_qshader.h:27
@ Q3DEFORM_NORMAL
Definition r_qshader.h:61
@ Q3DEFORM_TEXT3
Definition r_qshader.h:54
@ Q3DEFORM_TEXT5
Definition r_qshader.h:56
@ Q3DEFORM_TEXT0
Definition r_qshader.h:51
@ Q3DEFORM_AUTOSPRITE
Definition r_qshader.h:49
@ Q3DEFORM_PROJECTIONSHADOW
Definition r_qshader.h:48
@ Q3DEFORM_WAVE
Definition r_qshader.h:60
@ Q3DEFORM_TEXT1
Definition r_qshader.h:52
@ Q3DEFORM_TEXT2
Definition r_qshader.h:53
@ Q3DEFORM_NONE
Definition r_qshader.h:47
@ Q3DEFORM_AUTOSPRITE2
Definition r_qshader.h:50
@ Q3DEFORM_TEXT7
Definition r_qshader.h:58
@ Q3DEFORM_MOVE
Definition r_qshader.h:62
@ Q3DEFORM_TEXT6
Definition r_qshader.h:57
@ Q3DEFORM_TEXT4
Definition r_qshader.h:55
@ Q3DEFORM_BULGE
Definition r_qshader.h:59
@ Q3TCGEN_VECTOR
Definition r_qshader.h:104
@ Q3TCGEN_ENVIRONMENT
Definition r_qshader.h:102
@ Q3TCGEN_LIGHTMAP
Definition r_qshader.h:103
@ Q3TCGEN_TEXTURE
Definition r_qshader.h:101
@ r_stat_batch_fast_vertices
Definition r_stats.h:77
@ r_stat_batch_dynamic_triangles_because_deformvertexes_normal
Definition r_stats.h:110
@ r_stat_batch_dynamic_vertices_because_deformvertexes_move
Definition r_stats.h:121
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_wave
Definition r_stats.h:112
@ r_stat_batch_dynamic_batches_because_deformvertexes_autosprite
Definition r_stats.h:99
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_move
Definition r_stats.h:120
@ r_stat_batch_dynamic_vertices_because_deformvertexes_normal
Definition r_stats.h:109
@ r_stat_batch_dynamic_vertices_because_nogaps
Definition r_stats.h:141
@ r_stat_batch_dynamic_vertices_because_cvar
Definition r_stats.h:93
@ r_stat_batch_dynamic_batches_because_deformvertexes_bulge
Definition r_stats.h:115
@ r_stat_batch_dynamic_batches_because_tcmod_turbulent
Definition r_stats.h:135
@ r_stat_batch_dynamic_batches
Definition r_stats.h:83
@ r_stat_batch_dynamic_vertices_because_tcgen_lightmap
Definition r_stats.h:125
@ r_stat_batch_dynamic_surfaces_because_tcgen_environment
Definition r_stats.h:132
@ r_stat_batch_vertices
Definition r_stats.h:73
@ r_stat_batch_dynamic_batches_because_deformvertexes_move
Definition r_stats.h:119
@ r_stat_batch_copytriangles_vertices
Definition r_stats.h:81
@ r_stat_batch_dynamic_vertices_because_deformvertexes_wave
Definition r_stats.h:113
@ r_stat_batch_dynamic_triangles_because_cvar
Definition r_stats.h:94
@ r_stat_batch_dynamic_vertices_because_tcgen_environment
Definition r_stats.h:133
@ r_stat_batch_dynamic_batches_because_cvar
Definition r_stats.h:91
@ r_stat_batch_dynamic_batches_because_deformvertexes_wave
Definition r_stats.h:111
@ r_stat_batch_dynamic_triangles_because_deformvertexes_wave
Definition r_stats.h:114
@ r_stat_batch_dynamic_batches_because_lightmapvertex
Definition r_stats.h:95
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_normal
Definition r_stats.h:108
@ r_stat_batch_copytriangles_batches
Definition r_stats.h:79
@ r_stat_batch_dynamic_surfaces_because_tcgen_vector
Definition r_stats.h:128
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite2
Definition r_stats.h:104
@ r_stat_batch_dynamic_vertices
Definition r_stats.h:85
@ r_stat_batch_dynamic_triangles_because_deformvertexes_bulge
Definition r_stats.h:118
@ r_stat_batch_dynamic_triangles
Definition r_stats.h:86
@ r_stat_batch_dynamic_surfaces_because_nogaps
Definition r_stats.h:140
@ r_stat_batch_dynamic_vertices_because_tcgen_vector
Definition r_stats.h:129
@ r_stat_batch_triangles
Definition r_stats.h:74
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite
Definition r_stats.h:100
@ r_stat_batch_dynamicskeletal_triangles
Definition r_stats.h:90
@ r_stat_batch_dynamicskeletal_batches
Definition r_stats.h:87
@ r_stat_batch_dynamic_surfaces_because_tcgen_lightmap
Definition r_stats.h:124
@ r_stat_batch_surfaces
Definition r_stats.h:72
@ r_stat_batch_dynamicskeletal_vertices
Definition r_stats.h:89
@ r_stat_batch_dynamic_batches_because_nogaps
Definition r_stats.h:139
@ r_stat_batch_copytriangles_surfaces
Definition r_stats.h:80
@ r_stat_batch_fast_surfaces
Definition r_stats.h:76
@ r_stat_batch_dynamic_batches_because_tcgen_environment
Definition r_stats.h:131
@ r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite2
Definition r_stats.h:106
@ r_stat_batch_dynamic_surfaces_because_tcmod_turbulent
Definition r_stats.h:136
@ r_stat_batch_dynamic_batches_because_deformvertexes_normal
Definition r_stats.h:107
@ r_stat_batch_dynamic_surfaces_because_cvar
Definition r_stats.h:92
@ r_stat_batch_dynamic_batches_because_deformvertexes_autosprite2
Definition r_stats.h:103
@ r_stat_batch_dynamic_vertices_because_deformvertexes_bulge
Definition r_stats.h:117
@ r_stat_batch_dynamic_triangles_because_tcgen_environment
Definition r_stats.h:134
@ r_stat_batch_fast_triangles
Definition r_stats.h:78
@ r_stat_batch_dynamic_batches_because_tcgen_vector
Definition r_stats.h:127
@ r_stat_batch_dynamic_triangles_because_lightmapvertex
Definition r_stats.h:98
@ r_stat_batch_dynamic_triangles_because_nogaps
Definition r_stats.h:142
@ r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite
Definition r_stats.h:102
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_bulge
Definition r_stats.h:116
@ r_stat_batch_copytriangles_triangles
Definition r_stats.h:82
@ r_stat_batch_fast_batches
Definition r_stats.h:75
@ r_stat_batch_dynamicskeletal_surfaces
Definition r_stats.h:88
@ r_stat_batch_dynamic_vertices_because_lightmapvertex
Definition r_stats.h:97
@ r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite2
Definition r_stats.h:105
@ r_stat_batch_dynamic_batches_because_tcgen_lightmap
Definition r_stats.h:123
@ r_stat_batch_dynamic_surfaces_because_lightmapvertex
Definition r_stats.h:96
@ r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite
Definition r_stats.h:101
@ r_stat_batch_withgaps
Definition r_stats.h:71
@ r_stat_batch_dynamic_vertices_because_tcmod_turbulent
Definition r_stats.h:137
@ r_stat_batch_dynamic_triangles_because_tcgen_vector
Definition r_stats.h:130
@ r_stat_batch_dynamic_triangles_because_tcmod_turbulent
Definition r_stats.h:138
@ r_stat_batch_batches
Definition r_stats.h:70
@ r_stat_batch_dynamic_surfaces
Definition r_stats.h:84
@ r_stat_batch_dynamic_triangles_because_deformvertexes_move
Definition r_stats.h:122
@ r_stat_batch_dynamic_triangles_because_tcgen_lightmap
Definition r_stats.h:126
#define BATCHNEED_ARRAY_SKELETAL
Definition render.h:797
vec4 sw
q3wavefunc_t wavefunc
Definition r_qshader.h:178
float parms[Q3DEFORM_MAXPARMS]
Definition r_qshader.h:177
float waveparms[Q3WAVEPARMS]
Definition r_qshader.h:179
float parms[Q3TCGEN_MAXPARMS]
Definition r_qshader.h:145
int batchskeletalnumtransforms
Definition render.h:711
q3shaderinfo_layer_tcgen_t tcgen
Definition r_qshader.h:269
q3shaderinfo_deform_t deforms[Q3MAXDEFORMS]
static vec3_t right
Definition sv_user.c:305

Referenced by R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Mod_DrawShadowMap(), R_SetupShader_Surface(), R_Shadow_RenderLighting_VisibleLighting(), R_Water_AddWaterPlane(), and RSurf_FindWaterPlaneForSurface().

◆ RSurf_RenumberElements()

static void RSurf_RenumberElements ( const int inelement3i,
int outelement3i,
int  numelements,
int  adjust 
)
static

Definition at line 7416 of file gl_rmain.c.

7417{
7418 int i;
7419 for (i = 0;i < numelements;i++)
7421}

Referenced by RSurf_PrepareVerticesForBatch().

◆ RSurf_SetupDepthAndCulling()

void RSurf_SetupDepthAndCulling ( bool  ui)

Definition at line 8612 of file gl_rmain.c.

8613{
8614 // submodels are biased to avoid z-fighting with world surfaces that they
8615 // may be exactly overlapping (avoids z-fighting artifacts on certain
8616 // doors and things in Quake maps)
8621}
float biaspolygonoffset
float biaspolygonfactor

Referenced by R_DrawModelTextureSurfaceList(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_Sky(), and R_Shadow_RenderLighting().

◆ RSurf_UploadBuffersForBatch()

void RSurf_UploadBuffersForBatch ( void  )

Definition at line 7376 of file gl_rmain.c.

7377{
7378 // upload buffer data for generated vertex data (dynamicvertex case) or index data (copytriangles case) and models that lack it to begin with (e.g. DrawQ_FlushUI)
7379 // note that if rsurface.batchvertex3f_vertexbuffer is NULL, dynamicvertex is forced as we don't account for the proper base vertex here.
7398
7403
7411 R_Mesh_TexCoordPointer(5, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0);
7414}
void R_Mesh_VertexPointer(int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
void R_Mesh_TexCoordPointer(unsigned int unitnum, int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
void R_Mesh_ColorPointer(int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
#define GL_FLOAT
Definition glquake.h:124
#define GL_UNSIGNED_BYTE
Definition glquake.h:119

Referenced by R_SetupShader_Surface().

◆ ShaderModeInfo_GetShaderText()

static char * ShaderModeInfo_GetShaderText ( shadermodeinfo_t modeinfo,
qbool  printfromdisknotice,
qbool  builtinonly 
)
static

Definition at line 1006 of file gl_rmain.c.

1007{
1008 char *shaderstring;
1009 // if the mode has no filename we have to return the builtin string
1010 if (builtinonly || !modeinfo->filename)
1011 return Mem_strdup(r_main_mempool, modeinfo->builtinstring);
1012 // note that FS_LoadFile appends a 0 byte to make it a valid string
1013 shaderstring = (char *)FS_LoadFile(modeinfo->filename, r_main_mempool, false, NULL);
1014 if (shaderstring)
1015 {
1017 Con_DPrintf("Loading shaders from file %s...\n", modeinfo->filename);
1018 return shaderstring;
1019 }
1020 // fall back to builtinstring
1021 return Mem_strdup(r_main_mempool, modeinfo->builtinstring);
1022}

Referenced by R_GLSL_CompilePermutation().

◆ V_MakeViewIsometric()

void V_MakeViewIsometric ( void  )
extern

Definition at line 968 of file view.c.

969{
970 // when using isometric view to play normal games we have to rotate the camera to make the Ortho matrix do the right thing (forward as up the screen, etc)
974 vec3_t forward, left, up, org;
975 float t[16];
976
983 r_refdef.view.ortho_x = r_refdef.view.frustum_x; // used by VM_CL_R_SetView
984 r_refdef.view.ortho_y = r_refdef.view.frustum_y; // used by VM_CL_R_SetView
985
986 t[0] = v_isometric_xx.value;
987 t[1] = v_isometric_xy.value;
988 t[2] = v_isometric_xz.value;
989 t[3] = 0.0f;
990 t[4] = v_isometric_yx.value;
991 t[5] = v_isometric_yy.value;
992 t[6] = v_isometric_yz.value;
993 t[7] = 0.0f;
994 t[8] = v_isometric_zx.value;
995 t[9] = v_isometric_zy.value;
996 t[10] = v_isometric_zz.value;
997 t[11] = 0.0f;
998 t[12] = 0.0f;
999 t[13] = 0.0f;
1000 t[14] = 0.0f;
1001 t[15] = 1.0f;
1003
1004 // if the orientation is locked, extract the origin and create just a translate matrix to start with
1006 {
1007 vec3_t vx, vy, vz, origin;
1009 Matrix4x4_CreateTranslate(&r_refdef.view.matrix, origin[0], origin[1], origin[2]);
1010 }
1011
1018
1020 {
1024 }
1025}
cvar_t vid_pixelheight
Definition cl_screen.c:57
void Matrix4x4_FromArrayFloatGL(matrix4x4_t *out, const float in[16])
Definition matrixlib.c:1204
vec_t viewzoom
Definition client.h:795
float frustumscale_y
Definition render.h:408
float frustumscale_x
Definition render.h:408
cvar_t v_isometric_xx
Definition view.c:99
cvar_t v_isometric_rot_pitch
Definition view.c:111
cvar_t v_isometric_verticalfov
Definition view.c:98
cvar_t v_isometric_flipcullface
Definition view.c:117
cvar_t v_isometric_zz
Definition view.c:107
cvar_t v_isometric_zx
Definition view.c:105
cvar_t v_isometric_usevieworiginculling
Definition view.c:119
cvar_t v_isometric_relx
Definition view.c:114
cvar_t v_isometric_yy
Definition view.c:103
cvar_t v_isometric_relz
Definition view.c:116
cvar_t v_isometric_rely
Definition view.c:115
cvar_t v_isometric_zy
Definition view.c:106
cvar_t v_isometric_rot_roll
Definition view.c:113
cvar_t v_isometric_tz
Definition view.c:110
cvar_t v_isometric_ty
Definition view.c:109
cvar_t v_isometric_tx
Definition view.c:108
cvar_t v_isometric_yx
Definition view.c:102
cvar_t v_isometric_rot_yaw
Definition view.c:112
cvar_t v_isometric_xy
Definition view.c:100
cvar_t v_isometric_locked_orientation
Definition view.c:118
cvar_t v_isometric_xz
Definition view.c:101
cvar_t v_isometric_yz
Definition view.c:104

Referenced by R_RenderView().

Variable Documentation

◆ bboxedges

const float bboxedges[BBOXEDGES][6]
static
Initial value:
=
{
{ 0, 0, 0, 1, 1, 1 },
{ 0, 0, 0, 0, 1, 0 },
{ 0, 0, 0, 1, 0, 0 },
{ 0, 1, 0, 1, 1, 0 },
{ 1, 0, 0, 1, 1, 0 },
{ 0, 0, 1, 0, 1, 1 },
{ 0, 0, 1, 1, 0, 1 },
{ 0, 1, 1, 1, 1, 1 },
{ 1, 0, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 1, 0, 1 },
{ 0, 1, 0, 0, 1, 1 },
{ 1, 1, 0, 1, 1, 1 },
}

Definition at line 6049 of file gl_rmain.c.

6050{
6051 // whole box
6052 { 0, 0, 0, 1, 1, 1 },
6053 // bottom edges
6054 { 0, 0, 0, 0, 1, 0 },
6055 { 0, 0, 0, 1, 0, 0 },
6056 { 0, 1, 0, 1, 1, 0 },
6057 { 1, 0, 0, 1, 1, 0 },
6058 // top edges
6059 { 0, 0, 1, 0, 1, 1 },
6060 { 0, 0, 1, 1, 0, 1 },
6061 { 0, 1, 1, 1, 1, 1 },
6062 { 1, 0, 1, 1, 1, 1 },
6063 // vertical edges
6064 { 0, 0, 0, 0, 0, 1 },
6065 { 1, 0, 0, 1, 0, 1 },
6066 { 0, 1, 0, 0, 1, 1 },
6067 { 1, 1, 0, 1, 1, 1 },
6068};

Referenced by R_DrawBBoxMesh().

◆ bboxelements

const unsigned short bboxelements[36]
static
Initial value:
=
{
5, 1, 3, 5, 3, 7,
6, 2, 0, 6, 0, 4,
7, 3, 2, 7, 2, 6,
4, 0, 1, 4, 1, 5,
4, 5, 7, 4, 7, 6,
1, 0, 2, 1, 2, 3,
}

Definition at line 6038 of file gl_rmain.c.

6039{
6040 5, 1, 3, 5, 3, 7,
6041 6, 2, 0, 6, 0, 4,
6042 7, 3, 2, 7, 2, 6,
6043 4, 0, 1, 4, 1, 5,
6044 4, 5, 7, 4, 7, 6,
6045 1, 0, 2, 1, 2, 3,
6046};

Referenced by R_DrawBBoxMesh().

◆ builtinshaderstrings

const char* builtinshaderstrings[]
static
Initial value:
=
{
0
}

Definition at line 596 of file gl_rmain.c.

597{
598#include "shader_glsl.h"
5990
600};

◆ cl_decals_bias

cvar_t cl_decals_bias
extern

Definition at line 309 of file cl_particles.c.

309{CF_CLIENT | CF_ARCHIVE, "cl_decals_bias", "0.125", "distance to bias decals from surface to prevent depth fighting"};
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53

Referenced by CL_Particles_Init(), and R_DecalSystem_SplatTriangle().

◆ cl_decals_max

cvar_t cl_decals_max
extern

Definition at line 310 of file cl_particles.c.

310{CF_CLIENT | CF_ARCHIVE, "cl_decals_max", "4096", "maximum number of decals allowed to exist in the world at once"};

Referenced by CL_Particles_Init(), and R_DrawModelDecals_FadeEntity().

◆ cl_decals_models

cvar_t cl_decals_models
extern

Definition at line 308 of file cl_particles.c.

308{CF_CLIENT | CF_ARCHIVE, "cl_decals_models", "0", "enables decals on animated models"};

Referenced by CL_Particles_Init(), and R_DecalSystem_SplatEntity().

◆ cl_decals_newsystem_intensitymultiplier

cvar_t cl_decals_newsystem_intensitymultiplier
extern

Definition at line 305 of file cl_particles.c.

305{CF_CLIENT | CF_ARCHIVE, "cl_decals_newsystem_intensitymultiplier", "2", "boosts intensity of decals (because the distance fade can make them hard to see otherwise)"};

Referenced by CL_Particles_Init(), and R_DecalSystem_SplatTriangle().

◆ cl_locs_show

cvar_t cl_locs_show
extern

Definition at line 96 of file cl_main.c.

96{CF_CLIENT, "locs_show", "0", "shows defined locations for editing purposes"};

Referenced by CL_Init(), and R_RenderScene().

◆ componentorder

int componentorder[4] = {0, 1, 2, 3}
static

Definition at line 2905 of file gl_rmain.c.

2905{0, 1, 2, 3};

Referenced by R_LoadCubemap().

◆ decalskinframe

skinframe_t* decalskinframe
extern

Definition at line 187 of file cl_particles.c.

Referenced by R_DrawModelDecals_Entity(), R_InitParticleTexture(), and r_part_newmap().

◆ developer_texturelogging

cvar_t developer_texturelogging = {CF_CLIENT, "developer_texturelogging", "0", "produces a textures.log file containing names of skins and map textures the engine tried to load"}

Definition at line 231 of file gl_rmain.c.

231{CF_CLIENT, "developer_texturelogging", "0", "produces a textures.log file containing names of skins and map textures the engine tried to load"};

Referenced by GL_Main_Init(), and loadimagepixelsbgra().

◆ gl_fogblue

cvar_t gl_fogblue = {CF_CLIENT, "gl_fogblue","0.3", "nehahra fog color blue value (for Nehahra compatibility only)"}

Definition at line 151 of file gl_rmain.c.

151{CF_CLIENT, "gl_fogblue","0.3", "nehahra fog color blue value (for Nehahra compatibility only)"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ gl_fogdensity

cvar_t gl_fogdensity = {CF_CLIENT, "gl_fogdensity", "0.25", "nehahra fog density (recommend values below 0.1) (for Nehahra compatibility only)"}

Definition at line 148 of file gl_rmain.c.

148{CF_CLIENT, "gl_fogdensity", "0.25", "nehahra fog density (recommend values below 0.1) (for Nehahra compatibility only)"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ gl_fogenable

cvar_t gl_fogenable = {CF_CLIENT, "gl_fogenable", "0", "nehahra fog enable (for Nehahra compatibility only)"}

Definition at line 147 of file gl_rmain.c.

147{CF_CLIENT, "gl_fogenable", "0", "nehahra fog enable (for Nehahra compatibility only)"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ gl_fogend

cvar_t gl_fogend = {CF_CLIENT, "gl_fogend","0", "nehahra fog end distance (for Nehahra compatibility only)"}

Definition at line 153 of file gl_rmain.c.

153{CF_CLIENT, "gl_fogend","0", "nehahra fog end distance (for Nehahra compatibility only)"};

Referenced by GL_Main_Init().

◆ gl_foggreen

cvar_t gl_foggreen = {CF_CLIENT, "gl_foggreen","0.3", "nehahra fog color green value (for Nehahra compatibility only)"}

Definition at line 150 of file gl_rmain.c.

150{CF_CLIENT, "gl_foggreen","0.3", "nehahra fog color green value (for Nehahra compatibility only)"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ gl_fogred

cvar_t gl_fogred = {CF_CLIENT, "gl_fogred","0.3", "nehahra fog color red value (for Nehahra compatibility only)"}

Definition at line 149 of file gl_rmain.c.

149{CF_CLIENT, "gl_fogred","0.3", "nehahra fog color red value (for Nehahra compatibility only)"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ gl_fogstart

cvar_t gl_fogstart = {CF_CLIENT, "gl_fogstart", "0", "nehahra fog start distance (for Nehahra compatibility only)"}

Definition at line 152 of file gl_rmain.c.

152{CF_CLIENT, "gl_fogstart", "0", "nehahra fog start distance (for Nehahra compatibility only)"};

Referenced by GL_Main_Init().

◆ gl_lightmaps

cvar_t gl_lightmaps = {CF_CLIENT, "gl_lightmaps", "0", "draws only lightmaps, no texture (for level designers), a value of 2 keeps normalmap shading"}

Definition at line 233 of file gl_rmain.c.

233{CF_CLIENT, "gl_lightmaps", "0", "draws only lightmaps, no texture (for level designers), a value of 2 keeps normalmap shading"};

Referenced by GL_Main_Init(), R_GetCurrentTexture(), and R_SetupShader_Surface().

◆ gl_picmip

cvar_t gl_picmip
extern

Definition at line 29 of file gl_textures.c.

29{CF_CLIENT | CF_ARCHIVE, "gl_picmip", "0", "reduces resolution of textures by powers of 2, for example 1 will halve width/height, reducing texture memory usage by 75%"};

◆ gl_skyclip

cvar_t gl_skyclip = {CF_CLIENT, "gl_skyclip", "4608", "nehahra farclip distance - the real fog end (for Nehahra compatibility only)"}

Definition at line 154 of file gl_rmain.c.

154{CF_CLIENT, "gl_skyclip", "4608", "nehahra farclip distance - the real fog end (for Nehahra compatibility only)"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ irisvecs

float irisvecs[7][3] = {{0, 0, 0}, {-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}}
static

Definition at line 4150 of file gl_rmain.c.

4150{{0, 0, 0}, {-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}};

Referenced by R_HDR_UpdateIrisAdaptation().

◆ loadingscreentexture

◆ locboxelements

unsigned short locboxelements[6 *2 *3]
Initial value:
=
{
0, 1, 2, 0, 2, 3,
4, 5, 6, 4, 6, 7,
8, 9,10, 8,10,11,
12,13,14, 12,14,15,
16,17,18, 16,18,19,
20,21,22, 20,22,23
}

Definition at line 9104 of file gl_rmain.c.

9105{
9106 0, 1, 2, 0, 2, 3,
9107 4, 5, 6, 4, 6, 7,
9108 8, 9,10, 8,10,11,
9109 12,13,14, 12,14,15,
9110 16,17,18, 16,18,19,
9111 20,21,22, 20,22,23
9112};

Referenced by R_DrawLoc_Callback().

◆ locboxvertex3f

float locboxvertex3f[6 *4 *3]
Initial value:
=
{
1,0,1, 1,0,0, 1,1,0, 1,1,1,
0,1,1, 0,1,0, 0,0,0, 0,0,1,
1,1,1, 1,1,0, 0,1,0, 0,1,1,
0,0,1, 0,0,0, 1,0,0, 1,0,1,
0,0,1, 1,0,1, 1,1,1, 0,1,1,
1,0,0, 0,0,0, 0,1,0, 1,1,0
}

Definition at line 9094 of file gl_rmain.c.

9095{
9096 1,0,1, 1,0,0, 1,1,0, 1,1,1,
9097 0,1,1, 0,1,0, 0,0,0, 0,0,1,
9098 1,1,1, 1,1,0, 0,1,0, 0,1,1,
9099 0,0,1, 0,0,0, 1,0,0, 1,0,1,
9100 0,0,1, 1,0,1, 1,1,1, 0,1,1,
9101 1,0,0, 0,0,0, 0,1,0, 1,1,0
9102};

Referenced by R_DrawLoc_Callback().

◆ nomodelcolor4f

const float nomodelcolor4f[6 *4]
static
Initial value:
=
{
0.0f, 0.0f, 0.5f, 1.0f,
0.0f, 0.0f, 0.5f, 1.0f,
0.0f, 0.5f, 0.0f, 1.0f,
0.0f, 0.5f, 0.0f, 1.0f,
0.5f, 0.0f, 0.0f, 1.0f,
0.5f, 0.0f, 0.0f, 1.0f
}

Definition at line 6214 of file gl_rmain.c.

6215{
6216 0.0f, 0.0f, 0.5f, 1.0f,
6217 0.0f, 0.0f, 0.5f, 1.0f,
6218 0.0f, 0.5f, 0.0f, 1.0f,
6219 0.0f, 0.5f, 0.0f, 1.0f,
6220 0.5f, 0.0f, 0.0f, 1.0f,
6221 0.5f, 0.0f, 0.0f, 1.0f
6222};

Referenced by R_DrawNoModel_TransparentCallback().

◆ nomodelelement3i

const int nomodelelement3i[24]
static
Initial value:
=
{
5, 2, 0,
5, 1, 2,
5, 0, 3,
5, 3, 1,
0, 2, 4,
2, 1, 4,
3, 0, 4,
1, 3, 4
}

Definition at line 6180 of file gl_rmain.c.

6181{
6182 5, 2, 0,
6183 5, 1, 2,
6184 5, 0, 3,
6185 5, 3, 1,
6186 0, 2, 4,
6187 2, 1, 4,
6188 3, 0, 4,
6189 1, 3, 4
6190};

Referenced by R_DrawNoModel_TransparentCallback().

◆ nomodelelement3s

const unsigned short nomodelelement3s[24]
static
Initial value:
=
{
5, 2, 0,
5, 1, 2,
5, 0, 3,
5, 3, 1,
0, 2, 4,
2, 1, 4,
3, 0, 4,
1, 3, 4
}

Definition at line 6192 of file gl_rmain.c.

6193{
6194 5, 2, 0,
6195 5, 1, 2,
6196 5, 0, 3,
6197 5, 3, 1,
6198 0, 2, 4,
6199 2, 1, 4,
6200 3, 0, 4,
6201 1, 3, 4
6202};

Referenced by R_DrawNoModel_TransparentCallback().

◆ nomodelvertex3f

const float nomodelvertex3f[6 *3]
static
Initial value:
=
{
-16, 0, 0,
16, 0, 0,
0, -16, 0,
0, 16, 0,
0, 0, -16,
0, 0, 16
}

Definition at line 6204 of file gl_rmain.c.

6205{
6206 -16, 0, 0,
6207 16, 0, 0,
6208 0, -16, 0,
6209 0, 16, 0,
6210 0, 0, -16,
6211 0, 0, 16
6212};

Referenced by R_DrawNoModel_TransparentCallback().

◆ quadedges

const int quadedges[6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}}
static

Definition at line 7423 of file gl_rmain.c.

7423{{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}};

Referenced by RSurf_PrepareVerticesForBatch().

◆ r_batch_debugdynamicvertexpath

cvar_t r_batch_debugdynamicvertexpath = {CF_CLIENT | CF_ARCHIVE, "r_batch_debugdynamicvertexpath", "0", "force the dynamic batching code path for debugging purposes"}

Definition at line 239 of file gl_rmain.c.

239{CF_CLIENT | CF_ARCHIVE, "r_batch_debugdynamicvertexpath", "0", "force the dynamic batching code path for debugging purposes"};

Referenced by GL_Main_Init(), and RSurf_PrepareVerticesForBatch().

◆ r_batch_dynamicbuffer

cvar_t r_batch_dynamicbuffer = {CF_CLIENT | CF_ARCHIVE, "r_batch_dynamicbuffer", "0", "use vertex/index buffers for drawing dynamic and copytriangles batches"}

Definition at line 240 of file gl_rmain.c.

240{CF_CLIENT | CF_ARCHIVE, "r_batch_dynamicbuffer", "0", "use vertex/index buffers for drawing dynamic and copytriangles batches"};

Referenced by GL_Main_Init().

◆ r_batch_multidraw

cvar_t r_batch_multidraw = {CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw", "1", "issue multiple glDrawElements calls when rendering a batch of surfaces with the same texture (otherwise the index data is copied to make it one draw)"}

Definition at line 237 of file gl_rmain.c.

237{CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw", "1", "issue multiple glDrawElements calls when rendering a batch of surfaces with the same texture (otherwise the index data is copied to make it one draw)"};

Referenced by GL_Main_Init(), and RSurf_PrepareVerticesForBatch().

◆ r_batch_multidraw_mintriangles

cvar_t r_batch_multidraw_mintriangles = {CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw_mintriangles", "0", "minimum number of triangles to activate multidraw path (copying small groups of triangles may be faster)"}

Definition at line 238 of file gl_rmain.c.

238{CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw_mintriangles", "0", "minimum number of triangles to activate multidraw path (copying small groups of triangles may be faster)"};

Referenced by GL_Main_Init(), and RSurf_PrepareVerticesForBatch().

◆ r_bloom

cvar_t r_bloom = {CF_CLIENT | CF_ARCHIVE, "r_bloom", "0", "enables bloom effect (makes bright pixels affect neighboring pixels)"}

Definition at line 208 of file gl_rmain.c.

208{CF_CLIENT | CF_ARCHIVE, "r_bloom", "0", "enables bloom effect (makes bright pixels affect neighboring pixels)"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_StartFrame().

◆ r_bloom_blur

cvar_t r_bloom_blur = {CF_CLIENT | CF_ARCHIVE, "r_bloom_blur", "4", "how large the glow is"}

Definition at line 212 of file gl_rmain.c.

212{CF_CLIENT | CF_ARCHIVE, "r_bloom_blur", "4", "how large the glow is"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), R_Bloom_MakeTexture(), and R_Bloom_StartFrame().

◆ r_bloom_brighten

cvar_t r_bloom_brighten = {CF_CLIENT | CF_ARCHIVE, "r_bloom_brighten", "1", "how bright the glow is, after subtract/power"}

Definition at line 211 of file gl_rmain.c.

211{CF_CLIENT | CF_ARCHIVE, "r_bloom_brighten", "1", "how bright the glow is, after subtract/power"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_MakeTexture().

◆ r_bloom_colorexponent

cvar_t r_bloom_colorexponent = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorexponent", "1", "how exaggerated the glow is"}

Definition at line 214 of file gl_rmain.c.

214{CF_CLIENT | CF_ARCHIVE, "r_bloom_colorexponent", "1", "how exaggerated the glow is"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_MakeTexture().

◆ r_bloom_colorscale

cvar_t r_bloom_colorscale = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorscale", "1", "how bright the glow is"}

Definition at line 209 of file gl_rmain.c.

209{CF_CLIENT | CF_ARCHIVE, "r_bloom_colorscale", "1", "how bright the glow is"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_MakeTexture().

◆ r_bloom_colorsubtract

cvar_t r_bloom_colorsubtract = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorsubtract", "0.1", "reduces bloom colors by a certain amount"}

Definition at line 215 of file gl_rmain.c.

215{CF_CLIENT | CF_ARCHIVE, "r_bloom_colorsubtract", "0.1", "reduces bloom colors by a certain amount"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_BlendView().

◆ r_bloom_resolution

cvar_t r_bloom_resolution = {CF_CLIENT | CF_ARCHIVE, "r_bloom_resolution", "320", "what resolution to perform the bloom effect at (independent of screen resolution)"}

Definition at line 213 of file gl_rmain.c.

213{CF_CLIENT | CF_ARCHIVE, "r_bloom_resolution", "320", "what resolution to perform the bloom effect at (independent of screen resolution)"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_StartFrame().

◆ r_bloom_scenebrightness

cvar_t r_bloom_scenebrightness = {CF_CLIENT | CF_ARCHIVE, "r_bloom_scenebrightness", "1", "global rendering brightness when bloom is enabled"}

Definition at line 216 of file gl_rmain.c.

216{CF_CLIENT | CF_ARCHIVE, "r_bloom_scenebrightness", "1", "global rendering brightness when bloom is enabled"};

Referenced by GL_Main_Init(), and R_RenderView().

◆ r_bufferdata_buffer

◆ r_bufferdata_cycle

int r_bufferdata_cycle = 0
static

Definition at line 3617 of file gl_rmain.c.

Referenced by R_BufferData_NewFrame(), R_BufferData_Resize(), and R_BufferData_Store().

◆ r_buffermegs

cvar_t r_buffermegs[R_BUFFERDATA_COUNT]
Initial value:
=
{
{CF_CLIENT | CF_ARCHIVE, "r_buffermegs_vertex", "4", "vertex buffer size for one frame"},
{CF_CLIENT | CF_ARCHIVE, "r_buffermegs_index16", "1", "index buffer size for one frame (16bit indices)"},
{CF_CLIENT | CF_ARCHIVE, "r_buffermegs_index32", "1", "index buffer size for one frame (32bit indices)"},
{CF_CLIENT | CF_ARCHIVE, "r_buffermegs_uniform", "0.25", "uniform buffer size for one frame"},
}

Definition at line 249 of file gl_rmain.c.

250{
251 {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_vertex", "4", "vertex buffer size for one frame"},
252 {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_index16", "1", "index buffer size for one frame (16bit indices)"},
253 {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_index32", "1", "index buffer size for one frame (32bit indices)"},
254 {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_uniform", "0.25", "uniform buffer size for one frame"},
255};

Referenced by GL_Main_Init(), and R_BufferData_Resize().

◆ r_celoutlines

cvar_t r_celoutlines = {CF_CLIENT | CF_ARCHIVE, "r_celoutlines", "0", "cartoon-style outlines (requires r_shadow_deferred)"}

Definition at line 145 of file gl_rmain.c.

145{CF_CLIENT | CF_ARCHIVE, "r_celoutlines", "0", "cartoon-style outlines (requires r_shadow_deferred)"};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_celshading

cvar_t r_celshading = {CF_CLIENT | CF_ARCHIVE, "r_celshading", "0", "cartoon-style light shading (OpenGL 2.x only)"}

Definition at line 144 of file gl_rmain.c.

144{CF_CLIENT | CF_ARCHIVE, "r_celshading", "0", "cartoon-style light shading (OpenGL 2.x only)"}; // FIXME remove OpenGL 2.x only once implemented for DX9

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_colorfringe

cvar_t r_colorfringe = {CF_CLIENT | CF_ARCHIVE, "r_colorfringe", "0", "Chromatic aberration. Values higher than 0.025 will noticeably distort the image"}

Definition at line 189 of file gl_rmain.c.

189{CF_CLIENT | CF_ARCHIVE, "r_colorfringe", "0", "Chromatic aberration. Values higher than 0.025 will noticeably distort the image"};

Referenced by GL_Main_Init(), R_BlendView(), R_BlendView_IsTrivial(), and R_CompileShader_CheckStaticParms().

◆ r_compileshader_staticparms

unsigned int r_compileshader_staticparms[(SHADERSTATICPARMS_COUNT+0x1F) > > 5] = {0}
static

Definition at line 856 of file gl_rmain.c.

856{0};

Referenced by R_CompileShader_CheckStaticParms().

◆ r_cullentities_trace

cvar_t r_cullentities_trace = {CF_CLIENT, "r_cullentities_trace", "1", "probabistically cull invisible entities"}

Definition at line 101 of file gl_rmain.c.

101{CF_CLIENT, "r_cullentities_trace", "1", "probabistically cull invisible entities"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_delay

cvar_t r_cullentities_trace_delay = {CF_CLIENT, "r_cullentities_trace_delay", "1", "number of seconds until the entity gets actually culled"}

Definition at line 108 of file gl_rmain.c.

108{CF_CLIENT, "r_cullentities_trace_delay", "1", "number of seconds until the entity gets actually culled"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_enlarge

cvar_t r_cullentities_trace_enlarge = {CF_CLIENT, "r_cullentities_trace_enlarge", "0", "box enlargement for entity culling"}

Definition at line 105 of file gl_rmain.c.

105{CF_CLIENT, "r_cullentities_trace_enlarge", "0", "box enlargement for entity culling"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_entityocclusion

cvar_t r_cullentities_trace_entityocclusion = {CF_CLIENT, "r_cullentities_trace_entityocclusion", "1", "check for occluding entities such as doors, not just world hull"}

Definition at line 102 of file gl_rmain.c.

102{CF_CLIENT, "r_cullentities_trace_entityocclusion", "1", "check for occluding entities such as doors, not just world hull"};

Referenced by GL_Main_Init(), and R_CanSeeBox().

◆ r_cullentities_trace_expand

cvar_t r_cullentities_trace_expand = {CF_CLIENT, "r_cullentities_trace_expand", "0", "box expanded by this many units for entity culling"}

Definition at line 106 of file gl_rmain.c.

106{CF_CLIENT, "r_cullentities_trace_expand", "0", "box expanded by this many units for entity culling"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_eyejitter

cvar_t r_cullentities_trace_eyejitter = {CF_CLIENT, "r_cullentities_trace_eyejitter", "16", "randomly offset rays from the eye by this much to reduce the odds of flickering"}

Definition at line 109 of file gl_rmain.c.

109{CF_CLIENT, "r_cullentities_trace_eyejitter", "16", "randomly offset rays from the eye by this much to reduce the odds of flickering"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_pad

cvar_t r_cullentities_trace_pad = {CF_CLIENT, "r_cullentities_trace_pad", "8", "accept traces that hit within this many units of the box"}

Definition at line 107 of file gl_rmain.c.

107{CF_CLIENT, "r_cullentities_trace_pad", "8", "accept traces that hit within this many units of the box"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_samples

cvar_t r_cullentities_trace_samples = {CF_CLIENT, "r_cullentities_trace_samples", "2", "number of samples to test for entity culling (in addition to center sample)"}

Definition at line 103 of file gl_rmain.c.

103{CF_CLIENT, "r_cullentities_trace_samples", "2", "number of samples to test for entity culling (in addition to center sample)"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_tempentitysamples

cvar_t r_cullentities_trace_tempentitysamples = {CF_CLIENT, "r_cullentities_trace_tempentitysamples", "-1", "number of samples to test for entity culling of temp entities (including all CSQC entities), -1 disables trace culling on these entities to prevent flicker (pvs still applies)"}

Definition at line 104 of file gl_rmain.c.

104{CF_CLIENT, "r_cullentities_trace_tempentitysamples", "-1", "number of samples to test for entity culling of temp entities (including all CSQC entities), -1 disables trace culling on these entities to prevent flicker (pvs still applies)"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_currentscenetype

r_refdef_scene_type_t r_currentscenetype = RST_CLIENT
static

Definition at line 5574 of file gl_rmain.c.

Referenced by R_GetScenePointer(), and R_SelectScene().

◆ r_damageblur

Definition at line 60 of file gl_rmain.c.

60{CF_CLIENT | CF_ARCHIVE, "r_damageblur", "0", "screen motionblur based on damage - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"};

Referenced by GL_Main_Init(), R_Bloom_StartFrame(), and R_MotionBlurView().

◆ r_decalsystem_numqueued

int r_decalsystem_numqueued = 0

◆ r_decalsystem_queue

◆ r_deformvertexes

cvar_t r_deformvertexes = {CF_CLIENT, "r_deformvertexes", "1", "allows use of deformvertexes in shader files (can be turned off to check performance impact)"}

Definition at line 77 of file gl_rmain.c.

77{CF_CLIENT, "r_deformvertexes", "1", "allows use of deformvertexes in shader files (can be turned off to check performance impact)"};

Referenced by GL_Main_Init(), and RSurf_PrepareVerticesForBatch().

◆ r_depthfirst

cvar_t r_depthfirst = {CF_CLIENT | CF_ARCHIVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"}

Definition at line 72 of file gl_rmain.c.

72{CF_CLIENT | CF_ARCHIVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};

Referenced by GL_Main_Init(), and R_RenderScene().

◆ r_draw2d

cvar_t r_draw2d = {CF_CLIENT, "r_draw2d","1", "draw 2D stuff (dangerous to turn off)"}

Definition at line 97 of file gl_rmain.c.

97{CF_CLIENT, "r_draw2d","1", "draw 2D stuff (dangerous to turn off)"};

Referenced by DrawQ_FlushUI(), DrawQ_String_Scale(), and GL_Main_Init().

◆ r_drawdecals

cvar_t r_drawdecals
extern

Definition at line 2015 of file cl_particles.c.

2015{CF_CLIENT, "r_drawdecals", "1", "enables drawing of decals"};

Referenced by R_DrawModelDecals(), R_Particles_Init(), and R_Water_ProcessPlanes().

◆ r_drawentities

cvar_t r_drawentities = {CF_CLIENT, "r_drawentities","1", "draw entities (doors, players, projectiles, etc)"}

Definition at line 96 of file gl_rmain.c.

96{CF_CLIENT, "r_drawentities","1", "draw entities (doors, players, projectiles, etc)"};

Referenced by GL_Main_Init(), and R_RenderView().

◆ r_drawexteriormodel

cvar_t r_drawexteriormodel = {CF_CLIENT, "r_drawexteriormodel","1", "draw your player model (e.g. in chase cam, reflections)"}

Definition at line 100 of file gl_rmain.c.

100{CF_CLIENT, "r_drawexteriormodel","1", "draw your player model (e.g. in chase cam, reflections)"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_drawfog

cvar_t r_drawfog = {CF_CLIENT | CF_ARCHIVE, "r_drawfog", "1", "allows one to disable fog rendering"}

Definition at line 139 of file gl_rmain.c.

139{CF_CLIENT | CF_ARCHIVE, "r_drawfog", "1", "allows one to disable fog rendering"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ r_drawparticles

cvar_t r_drawparticles
extern

Definition at line 2011 of file cl_particles.c.

2011{CF_CLIENT, "r_drawparticles", "1", "enables drawing of particles"};

Referenced by R_DrawParticles(), R_Particles_Init(), and R_Water_ProcessPlanes().

◆ r_drawportals

cvar_t r_drawportals = {CF_CLIENT, "r_drawportals", "0", "shows portals (separating polygons) in world interior in quake1 maps"}

Definition at line 95 of file gl_rmain.c.

95{CF_CLIENT, "r_drawportals", "0", "shows portals (separating polygons) in world interior in quake1 maps"};

Referenced by GL_Main_Init(), and R_RenderScene().

◆ r_drawviewmodel

cvar_t r_drawviewmodel = {CF_CLIENT, "r_drawviewmodel","1", "draw your weapon model"}

Definition at line 99 of file gl_rmain.c.

99{CF_CLIENT, "r_drawviewmodel","1", "draw your weapon model"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_drawworld

cvar_t r_drawworld = {CF_CLIENT, "r_drawworld","1", "draw world (most static stuff)"}

Definition at line 98 of file gl_rmain.c.

98{CF_CLIENT, "r_drawworld","1", "draw world (most static stuff)"};

Referenced by CL_ClearState(), GL_Main_Init(), VM_CL_R_ClearScene(), and VM_CL_R_SetView().

◆ r_dynamic

cvar_t r_dynamic = {CF_CLIENT | CF_ARCHIVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"}

Definition at line 121 of file gl_rmain.c.

121{CF_CLIENT | CF_ARCHIVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"};

Referenced by CL_RelinkLightFlashes(), GL_Main_Init(), R_UpdateVariables(), and R_Water_ProcessPlanes().

◆ r_farclip_base

cvar_t r_farclip_base = {CF_CLIENT, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"}

Definition at line 74 of file gl_rmain.c.

74{CF_CLIENT, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"};

Referenced by GL_Main_Init(), and R_UpdateVariables().

◆ r_farclip_world

cvar_t r_farclip_world = {CF_CLIENT, "r_farclip_world", "2", "adds map size to farclip multiplied by this value"}

Definition at line 75 of file gl_rmain.c.

75{CF_CLIENT, "r_farclip_world", "2", "adds map size to farclip multiplied by this value"};

Referenced by GL_Main_Init(), and R_UpdateVariables().

◆ r_fb

◆ r_fog_clear

cvar_t r_fog_clear = {CF_CLIENT, "r_fog_clear", "1", "clears renderbuffer with fog color before render starts"}

Definition at line 138 of file gl_rmain.c.

138{CF_CLIENT, "r_fog_clear", "1", "clears renderbuffer with fog color before render starts"};

Referenced by GL_Main_Init(), and R_ClearScreen().

◆ r_fog_exp2

cvar_t r_fog_exp2 = {CF_CLIENT, "r_fog_exp2", "0", "uses GL_EXP2 fog (as in Nehahra) rather than realistic GL_EXP fog"}

Definition at line 137 of file gl_rmain.c.

137{CF_CLIENT, "r_fog_exp2", "0", "uses GL_EXP2 fog (as in Nehahra) rather than realistic GL_EXP fog"};

Referenced by GL_Main_Init(), R_BuildFogTexture(), and R_UpdateFog().

◆ r_framedata_mem

◆ r_framedatasize

cvar_t r_framedatasize = {CF_CLIENT | CF_ARCHIVE, "r_framedatasize", "0.5", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"}

Definition at line 248 of file gl_rmain.c.

248{CF_CLIENT | CF_ARCHIVE, "r_framedatasize", "0.5", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"};

Referenced by GL_Main_Init(), R_FrameData_Alloc(), and R_FrameData_Resize().

◆ r_fullbright

cvar_t r_fullbright = {CF_CLIENT, "r_fullbright","0", "makes map very bright and renders faster"}

Definition at line 112 of file gl_rmain.c.

112{CF_CLIENT, "r_fullbright","0", "makes map very bright and renders faster"};

Referenced by CL_RelinkStaticEntities(), CL_RelinkWorld(), CL_UpdateEntityShading_Entity(), CL_UpdateNetworkEntity(), CSQC_AddRenderEdict(), GL_Main_Init(), RSurf_ActiveModelEntity(), and VM_CL_makestatic().

◆ r_fullbright_directed

cvar_t r_fullbright_directed = {CF_CLIENT, "r_fullbright_directed", "0", "render fullbright things (unlit worldmodel and EF_FULLBRIGHT entities, but not fullbright shaders) using a constant light direction instead to add more depth while keeping uniform brightness"}

Definition at line 114 of file gl_rmain.c.

114{CF_CLIENT, "r_fullbright_directed", "0", "render fullbright things (unlit worldmodel and EF_FULLBRIGHT entities, but not fullbright shaders) using a constant light direction instead to add more depth while keeping uniform brightness"};

Referenced by CL_UpdateEntityShading_Entity(), GL_Main_Init(), and RSurf_ActiveModelEntity().

◆ r_fullbright_directed_ambient

cvar_t r_fullbright_directed_ambient = {CF_CLIENT, "r_fullbright_directed_ambient", "0.5", "ambient light multiplier for directed fullbright"}

Definition at line 115 of file gl_rmain.c.

115{CF_CLIENT, "r_fullbright_directed_ambient", "0.5", "ambient light multiplier for directed fullbright"};

Referenced by CL_UpdateEntityShading_GetDirectedFullbright(), and GL_Main_Init().

◆ r_fullbright_directed_diffuse

cvar_t r_fullbright_directed_diffuse = {CF_CLIENT, "r_fullbright_directed_diffuse", "0.75", "diffuse light multiplier for directed fullbright"}

Definition at line 116 of file gl_rmain.c.

116{CF_CLIENT, "r_fullbright_directed_diffuse", "0.75", "diffuse light multiplier for directed fullbright"};

Referenced by CL_UpdateEntityShading_GetDirectedFullbright(), and GL_Main_Init().

◆ r_fullbright_directed_pitch

cvar_t r_fullbright_directed_pitch = {CF_CLIENT, "r_fullbright_directed_pitch", "20", "constant pitch direction ('height') of the fake light source to use for fullbright"}

Definition at line 117 of file gl_rmain.c.

117{CF_CLIENT, "r_fullbright_directed_pitch", "20", "constant pitch direction ('height') of the fake light source to use for fullbright"};

Referenced by CL_UpdateEntityShading_GetDirectedFullbright(), and GL_Main_Init().

◆ r_fullbright_directed_pitch_relative

cvar_t r_fullbright_directed_pitch_relative = {CF_CLIENT, "r_fullbright_directed_pitch_relative", "0", "whether r_fullbright_directed_pitch is interpreted as absolute (0) or relative (1) pitch"}

Definition at line 118 of file gl_rmain.c.

118{CF_CLIENT, "r_fullbright_directed_pitch_relative", "0", "whether r_fullbright_directed_pitch is interpreted as absolute (0) or relative (1) pitch"};

Referenced by CL_UpdateEntityShading_GetDirectedFullbright(), and GL_Main_Init().

◆ r_fullbrights

cvar_t r_fullbrights = {CF_CLIENT | CF_ARCHIVE, "r_fullbrights", "1", "enables glowing pixels in quake textures (changes need r_restart to take effect)"}

Definition at line 122 of file gl_rmain.c.

122{CF_CLIENT | CF_ARCHIVE, "r_fullbrights", "1", "enables glowing pixels in quake textures (changes need r_restart to take effect)"};

Referenced by GL_Main_Init(), Mod_IDP0_Load(), Mod_Q1BSP_LoadTextures(), and R_LoadQWSkin().

◆ r_fxaa

cvar_t r_fxaa = {CF_CLIENT | CF_ARCHIVE, "r_fxaa", "0", "fast approximate anti aliasing"}

Definition at line 190 of file gl_rmain.c.

190{CF_CLIENT | CF_ARCHIVE, "r_fxaa", "0", "fast approximate anti aliasing"};

Referenced by GL_Main_Init(), R_BlendView_IsTrivial(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_deluxemapping

cvar_t r_glsl_deluxemapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"}

Definition at line 171 of file gl_rmain.c.

171{CF_CLIENT | CF_ARCHIVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping

cvar_t r_glsl_offsetmapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"}

Definition at line 172 of file gl_rmain.c.

172{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_lod

cvar_t r_glsl_offsetmapping_lod = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod", "0", "apply distance-based level-of-detail correction to number of offsetmappig steps, effectively making it render faster on large open-area maps"}

Definition at line 178 of file gl_rmain.c.

178{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod", "0", "apply distance-based level-of-detail correction to number of offsetmappig steps, effectively making it render faster on large open-area maps"};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_offsetmapping_lod_distance

cvar_t r_glsl_offsetmapping_lod_distance = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod_distance", "32", "first LOD level distance, second level (-50% steps) is 2x of this, third (33%) - 3x etc."}

Definition at line 179 of file gl_rmain.c.

179{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod_distance", "32", "first LOD level distance, second level (-50% steps) is 2x of this, third (33%) - 3x etc."};

Referenced by GL_Main_Init(), R_CompileShader_CheckStaticParms(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_reliefmapping

cvar_t r_glsl_offsetmapping_reliefmapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping", "0", "relief mapping effect (higher quality)"}

Definition at line 174 of file gl_rmain.c.

174{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping", "0", "relief mapping effect (higher quality)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_reliefmapping_refinesteps

cvar_t r_glsl_offsetmapping_reliefmapping_refinesteps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_refinesteps", "5", "relief mapping refine steps (these are a binary search executed as the last step as given by r_glsl_offsetmapping_reliefmapping_steps)"}

Definition at line 176 of file gl_rmain.c.

176{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_refinesteps", "5", "relief mapping refine steps (these are a binary search executed as the last step as given by r_glsl_offsetmapping_reliefmapping_steps)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_reliefmapping_steps

cvar_t r_glsl_offsetmapping_reliefmapping_steps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_steps", "10", "relief mapping steps (note: too high values may be not supported by your GPU)"}

Definition at line 175 of file gl_rmain.c.

175{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_steps", "10", "relief mapping steps (note: too high values may be not supported by your GPU)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_scale

cvar_t r_glsl_offsetmapping_scale = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_scale", "0.04", "how deep the offset mapping effect is"}

Definition at line 177 of file gl_rmain.c.

177{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_scale", "0.04", "how deep the offset mapping effect is"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_steps

cvar_t r_glsl_offsetmapping_steps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_steps", "2", "offset mapping steps (note: too high values may be not supported by your GPU)"}

Definition at line 173 of file gl_rmain.c.

173{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_steps", "2", "offset mapping steps (note: too high values may be not supported by your GPU)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_permutation

◆ r_glsl_permutationarray

memexpandablearray_t r_glsl_permutationarray

storage for permutations linked in the hash table

Definition at line 938 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), R_GLSL_FindPermutation(), and R_GLSL_Restart_f().

◆ r_glsl_permutationhash

information about each possible shader permutation

Definition at line 934 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), R_GLSL_FindPermutation(), and R_GLSL_Restart_f().

◆ r_glsl_postprocess

cvar_t r_glsl_postprocess = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess", "0", "use a GLSL postprocessing shader"}

Definition at line 180 of file gl_rmain.c.

180{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess", "0", "use a GLSL postprocessing shader"};

Referenced by GL_Main_Init(), R_BlendView(), R_BlendView_IsTrivial(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_postprocess_uservec1

cvar_t r_glsl_postprocess_uservec1 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1", "0 0 0 0", "a 4-component vector to pass as uservec1 to the postprocessing shader (only useful if default.glsl has been customized)"}

Definition at line 181 of file gl_rmain.c.

181{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1", "0 0 0 0", "a 4-component vector to pass as uservec1 to the postprocessing shader (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_glsl_postprocess_uservec1_enable

cvar_t r_glsl_postprocess_uservec1_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1_enable", "1", "enables postprocessing uservec1 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}

Definition at line 185 of file gl_rmain.c.

185{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1_enable", "1", "enables postprocessing uservec1 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_postprocess_uservec2

cvar_t r_glsl_postprocess_uservec2 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2", "0 0 0 0", "a 4-component vector to pass as uservec2 to the postprocessing shader (only useful if default.glsl has been customized)"}

Definition at line 182 of file gl_rmain.c.

182{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2", "0 0 0 0", "a 4-component vector to pass as uservec2 to the postprocessing shader (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_glsl_postprocess_uservec2_enable

cvar_t r_glsl_postprocess_uservec2_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2_enable", "1", "enables postprocessing uservec2 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}

Definition at line 186 of file gl_rmain.c.

186{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2_enable", "1", "enables postprocessing uservec2 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_postprocess_uservec3

cvar_t r_glsl_postprocess_uservec3 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3", "0 0 0 0", "a 4-component vector to pass as uservec3 to the postprocessing shader (only useful if default.glsl has been customized)"}

Definition at line 183 of file gl_rmain.c.

183{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3", "0 0 0 0", "a 4-component vector to pass as uservec3 to the postprocessing shader (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_glsl_postprocess_uservec3_enable

cvar_t r_glsl_postprocess_uservec3_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3_enable", "1", "enables postprocessing uservec3 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}

Definition at line 187 of file gl_rmain.c.

187{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3_enable", "1", "enables postprocessing uservec3 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_postprocess_uservec4

cvar_t r_glsl_postprocess_uservec4 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4", "0 0 0 0", "a 4-component vector to pass as uservec4 to the postprocessing shader (only useful if default.glsl has been customized)"}

Definition at line 184 of file gl_rmain.c.

184{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4", "0 0 0 0", "a 4-component vector to pass as uservec4 to the postprocessing shader (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_glsl_postprocess_uservec4_enable

cvar_t r_glsl_postprocess_uservec4_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4_enable", "1", "enables postprocessing uservec4 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}

Definition at line 188 of file gl_rmain.c.

188{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4_enable", "1", "enables postprocessing uservec4 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_saturation

cvar_t r_glsl_saturation = {CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation", "1", "saturation multiplier (only working in glsl!)"}

Definition at line 242 of file gl_rmain.c.

242{CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation", "1", "saturation multiplier (only working in glsl!)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_BlendView_IsTrivial().

◆ r_glsl_saturation_redcompensate

cvar_t r_glsl_saturation_redcompensate = {CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation_redcompensate", "0", "a 'vampire sight' addition to desaturation effect, does compensation for red color, r_glsl_restart is required"}

Definition at line 243 of file gl_rmain.c.

243{CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation_redcompensate", "0", "a 'vampire sight' addition to desaturation effect, does compensation for red color, r_glsl_restart is required"};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_skeletal

cvar_t r_glsl_skeletal = {CF_CLIENT | CF_ARCHIVE, "r_glsl_skeletal", "1", "render skeletal models faster using a gpu-skinning technique"}

Definition at line 170 of file gl_rmain.c.

170{CF_CLIENT | CF_ARCHIVE, "r_glsl_skeletal", "1", "render skeletal models faster using a gpu-skinning technique"};

Referenced by GL_Main_Init(), and R_UpdateVariables().

◆ r_glsl_vertextextureblend_usebothalphas

cvar_t r_glsl_vertextextureblend_usebothalphas = {CF_CLIENT | CF_ARCHIVE, "r_glsl_vertextextureblend_usebothalphas", "0", "use both alpha layers on vertex blended surfaces, each alpha layer sets amount of 'blend leak' on another layer, requires mod_q3shader_force_terrain_alphaflag on."}

Definition at line 245 of file gl_rmain.c.

245{CF_CLIENT | CF_ARCHIVE, "r_glsl_vertextextureblend_usebothalphas", "0", "use both alpha layers on vertex blended surfaces, each alpha layer sets amount of 'blend leak' on another layer, requires mod_q3shader_force_terrain_alphaflag on."};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_gpuskeletal

qbool r_gpuskeletal
static

Definition at line 52 of file gl_rmain.c.

Referenced by R_AnimCache_GetEntity(), and R_UpdateVariables().

◆ r_hdr_glowintensity

cvar_t r_hdr_glowintensity = {CF_CLIENT | CF_ARCHIVE, "r_hdr_glowintensity", "1", "how bright light emitting textures should appear"}

Definition at line 219 of file gl_rmain.c.

219{CF_CLIENT | CF_ARCHIVE, "r_hdr_glowintensity", "1", "how bright light emitting textures should appear"};

Referenced by CL_UpdateEntityShading_Entity(), GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_SetupShader_Surface().

◆ r_hdr_irisadaptation

cvar_t r_hdr_irisadaptation = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation", "0", "adjust scene brightness according to light intensity at player location"}

Definition at line 220 of file gl_rmain.c.

220{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation", "0", "adjust scene brightness according to light intensity at player location"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_fade_down

cvar_t r_hdr_irisadaptation_fade_down = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_down", "0.5", "fade rate at which value adjusts to brightness"}

Definition at line 226 of file gl_rmain.c.

226{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_down", "0.5", "fade rate at which value adjusts to brightness"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_fade_up

cvar_t r_hdr_irisadaptation_fade_up = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_up", "0.1", "fade rate at which value adjusts to darkness"}

Definition at line 225 of file gl_rmain.c.

225{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_up", "0.1", "fade rate at which value adjusts to darkness"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_maxvalue

cvar_t r_hdr_irisadaptation_maxvalue = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_maxvalue", "4", "maximum value that can result from multiplier / brightness"}

Definition at line 223 of file gl_rmain.c.

223{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_maxvalue", "4", "maximum value that can result from multiplier / brightness"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_minvalue

cvar_t r_hdr_irisadaptation_minvalue = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_minvalue", "0.5", "minimum value that can result from multiplier / brightness"}

Definition at line 222 of file gl_rmain.c.

222{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_minvalue", "0.5", "minimum value that can result from multiplier / brightness"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_multiplier

cvar_t r_hdr_irisadaptation_multiplier = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_multiplier", "2", "brightness at which value will be 1.0"}

Definition at line 221 of file gl_rmain.c.

221{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_multiplier", "2", "brightness at which value will be 1.0"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_radius

cvar_t r_hdr_irisadaptation_radius = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_radius", "15", "lighting within this many units of the eye is averaged"}

Definition at line 227 of file gl_rmain.c.

227{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_radius", "15", "lighting within this many units of the eye is averaged"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_value

cvar_t r_hdr_irisadaptation_value = {CF_CLIENT, "r_hdr_irisadaptation_value", "1", "current value as scenebrightness multiplier, changes continuously when irisadaptation is active"}

Definition at line 224 of file gl_rmain.c.

224{CF_CLIENT, "r_hdr_irisadaptation_value", "1", "current value as scenebrightness multiplier, changes continuously when irisadaptation is active"};

Referenced by GL_Main_Init(), R_HDR_UpdateIrisAdaptation(), and R_RenderView().

◆ r_hdr_scenebrightness

cvar_t r_hdr_scenebrightness = {CF_CLIENT | CF_ARCHIVE, "r_hdr_scenebrightness", "1", "global rendering brightness"}

Definition at line 218 of file gl_rmain.c.

218{CF_CLIENT | CF_ARCHIVE, "r_hdr_scenebrightness", "1", "global rendering brightness"};

Referenced by GL_Main_Init(), M_Menu_Options_AdjustSliders(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Draw(), M_Options_Graphics_Draw(), and R_RenderView().

◆ r_lerplightstyles

cvar_t r_lerplightstyles = {CF_CLIENT | CF_ARCHIVE, "r_lerplightstyles", "0", "enable animation smoothing on flickering lights"}

Definition at line 205 of file gl_rmain.c.

205{CF_CLIENT | CF_ARCHIVE, "r_lerplightstyles", "0", "enable animation smoothing on flickering lights"};

Referenced by CL_RelinkLightFlashes(), GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), and M_Options_Effects_Draw().

◆ r_lerpmodels

cvar_t r_lerpmodels = {CF_CLIENT | CF_ARCHIVE, "r_lerpmodels", "1", "enables animation smoothing on models"}

Definition at line 203 of file gl_rmain.c.

203{CF_CLIENT | CF_ARCHIVE, "r_lerpmodels", "1", "enables animation smoothing on models"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and VM_FrameBlendFromFrameGroupBlend().

◆ r_lerpsprites

cvar_t r_lerpsprites = {CF_CLIENT | CF_ARCHIVE, "r_lerpsprites", "0", "enables animation smoothing on sprites"}

Definition at line 202 of file gl_rmain.c.

202{CF_CLIENT | CF_ARCHIVE, "r_lerpsprites", "0", "enables animation smoothing on sprites"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and VM_FrameBlendFromFrameGroupBlend().

◆ r_loaddds

qbool r_loaddds
static

Definition at line 50 of file gl_rmain.c.

Referenced by gl_main_start(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_loadfog

◆ r_loadgloss

qbool r_loadgloss
static

Definition at line 48 of file gl_rmain.c.

Referenced by gl_main_start(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_loadnormalmap

qbool r_loadnormalmap
static

◆ r_lockpvs

cvar_t r_lockpvs
extern

Definition at line 29 of file gl_rsurf.c.

29{CF_CLIENT, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"};

Referenced by GL_Surf_Init(), R_View_WorldVisibility(), and R_Water_StartFrame().

◆ r_lockvisibility

cvar_t r_lockvisibility
extern

Definition at line 30 of file gl_rsurf.c.

30{CF_CLIENT, "r_lockvisibility", "0", "disables visibility updates, allows you to walk around and inspect what is visible from a given viewpoint in the map (anything offscreen at the moment this is enabled will not be drawn)"};

Referenced by GL_Surf_Init(), R_View_SetFrustum(), R_View_WorldVisibility(), and R_Water_StartFrame().

◆ r_main_mempool

◆ r_main_texturepool

◆ r_maxqueries

unsigned int r_maxqueries

◆ r_maxsurfacelist

int r_maxsurfacelist = 0

Definition at line 10032 of file gl_rmain.c.

Referenced by R_DrawModelSurfaces().

◆ r_motionblur

Definition at line 59 of file gl_rmain.c.

59{CF_CLIENT | CF_ARCHIVE, "r_motionblur", "0", "screen motionblur - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"};

Referenced by GL_Main_Init(), R_Bloom_StartFrame(), and R_MotionBlurView().

◆ r_motionblur_averaging

cvar_t r_motionblur_averaging = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_averaging", "0.1", "sliding average reaction time for velocity (higher = slower adaption to change)"}

Definition at line 61 of file gl_rmain.c.

61{CF_CLIENT | CF_ARCHIVE, "r_motionblur_averaging", "0.1", "sliding average reaction time for velocity (higher = slower adaption to change)"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_maxblur

cvar_t r_motionblur_maxblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_maxblur", "0.9", "maxmimum amount of blur"}

Definition at line 64 of file gl_rmain.c.

64{CF_CLIENT | CF_ARCHIVE, "r_motionblur_maxblur", "0.9", "maxmimum amount of blur"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_minblur

cvar_t r_motionblur_minblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_minblur", "0.5", "factor of blur to apply at all times (always have this amount of blur no matter what the other factors are)"}

Definition at line 63 of file gl_rmain.c.

63{CF_CLIENT | CF_ARCHIVE, "r_motionblur_minblur", "0.5", "factor of blur to apply at all times (always have this amount of blur no matter what the other factors are)"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_mousefactor

cvar_t r_motionblur_mousefactor = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor", "2", "factoring in of mouse acceleration to the blur equation - the faster the player turns their mouse, the more blur they get"}

Definition at line 68 of file gl_rmain.c.

68{CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor", "2", "factoring in of mouse acceleration to the blur equation - the faster the player turns their mouse, the more blur they get"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_mousefactor_maxspeed

cvar_t r_motionblur_mousefactor_maxspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_maxspeed", "50", "upper value of mouse acceleration when it reaches the peak factor into blur equation"}

Definition at line 70 of file gl_rmain.c.

70{CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_maxspeed", "50", "upper value of mouse acceleration when it reaches the peak factor into blur equation"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_mousefactor_minspeed

cvar_t r_motionblur_mousefactor_minspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_minspeed", "0", "lower value of mouse acceleration when it starts to factor into blur equation"}

Definition at line 69 of file gl_rmain.c.

69{CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_minspeed", "0", "lower value of mouse acceleration when it starts to factor into blur equation"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_randomize

cvar_t r_motionblur_randomize = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_randomize", "0.1", "randomizing coefficient to workaround ghosting"}

Definition at line 62 of file gl_rmain.c.

62{CF_CLIENT | CF_ARCHIVE, "r_motionblur_randomize", "0.1", "randomizing coefficient to workaround ghosting"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_velocityfactor

cvar_t r_motionblur_velocityfactor = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor", "1", "factoring in of player velocity to the blur equation - the faster the player moves around the map, the more blur they get"}

Definition at line 65 of file gl_rmain.c.

65{CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor", "1", "factoring in of player velocity to the blur equation - the faster the player moves around the map, the more blur they get"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_velocityfactor_maxspeed

cvar_t r_motionblur_velocityfactor_maxspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_maxspeed", "800", "upper value of velocity when it reaches the peak factor into blur equation"}

Definition at line 67 of file gl_rmain.c.

67{CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_maxspeed", "800", "upper value of velocity when it reaches the peak factor into blur equation"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_velocityfactor_minspeed

cvar_t r_motionblur_velocityfactor_minspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_minspeed", "400", "lower value of velocity when it starts to factor into blur equation"}

Definition at line 66 of file gl_rmain.c.

66{CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_minspeed", "400", "lower value of velocity when it starts to factor into blur equation"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_nearclip

cvar_t r_nearclip = {CF_CLIENT, "r_nearclip", "1", "distance from camera of nearclip plane" }

Definition at line 76 of file gl_rmain.c.

76{CF_CLIENT, "r_nearclip", "1", "distance from camera of nearclip plane" };

Referenced by GL_Main_Init(), R_UpdateVariables(), and R_View_WorldVisibility().

◆ r_nolerp_list

Definition at line 204 of file gl_rmain.c.

204{CF_CLIENT | CF_ARCHIVE, "r_nolerp_list", "progs/v_nail.mdl,progs/v_nail2.mdl,progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl", "comma separated list of models that will not have their animations smoothed"};

Referenced by GL_Main_Init(), and Mod_IDP0_Load().

◆ r_numqueries

unsigned int r_numqueries

◆ r_polygonoffset_decals_factor

cvar_t r_polygonoffset_decals_factor = {CF_CLIENT, "r_polygonoffset_decals_factor", "0", "biases depth values of decals to prevent z-fighting artifacts"}

Definition at line 135 of file gl_rmain.c.

135{CF_CLIENT, "r_polygonoffset_decals_factor", "0", "biases depth values of decals to prevent z-fighting artifacts"};

Referenced by GL_Main_Init(), and R_DrawModelDecals_Entity().

◆ r_polygonoffset_decals_offset

cvar_t r_polygonoffset_decals_offset = {CF_CLIENT, "r_polygonoffset_decals_offset", "-14", "biases depth values of decals to prevent z-fighting artifacts"}

Definition at line 136 of file gl_rmain.c.

136{CF_CLIENT, "r_polygonoffset_decals_offset", "-14", "biases depth values of decals to prevent z-fighting artifacts"};

Referenced by GL_Main_Init(), and R_DrawModelDecals_Entity().

◆ r_polygonoffset_submodel_factor

cvar_t r_polygonoffset_submodel_factor = {CF_CLIENT, "r_polygonoffset_submodel_factor", "0", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"}

Definition at line 133 of file gl_rmain.c.

133{CF_CLIENT, "r_polygonoffset_submodel_factor", "0", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"};

Referenced by GL_Main_Init(), and RSurf_ActiveModelEntity().

◆ r_polygonoffset_submodel_offset

cvar_t r_polygonoffset_submodel_offset = {CF_CLIENT, "r_polygonoffset_submodel_offset", "14", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"}

Definition at line 134 of file gl_rmain.c.

134{CF_CLIENT, "r_polygonoffset_submodel_offset", "14", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"};

Referenced by GL_Main_Init(), and RSurf_ActiveModelEntity().

◆ r_q1bsp_lightmap_updates_combine

cvar_t r_q1bsp_lightmap_updates_combine = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_combine", "2", "combine lightmap texture updates to make fewer glTexSubImage2D calls, modes: 0 = immediately upload lightmaps (may be thousands of small 3x3 updates), 1 = combine to one call, 2 = combine to one full texture update (glTexImage2D) which tells the driver it does not need to lock the resource (faster on most drivers)"}

Definition at line 258 of file gl_rmain.c.

258{CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_combine", "2", "combine lightmap texture updates to make fewer glTexSubImage2D calls, modes: 0 = immediately upload lightmaps (may be thousands of small 3x3 updates), 1 = combine to one call, 2 = combine to one full texture update (glTexImage2D) which tells the driver it does not need to lock the resource (faster on most drivers)"};

Referenced by GL_Main_Init(), R_BuildLightMap(), and R_DrawModelSurfaces().

◆ r_q1bsp_lightmap_updates_enabled

cvar_t r_q1bsp_lightmap_updates_enabled = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"}

Definition at line 257 of file gl_rmain.c.

257{CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"};

Referenced by GL_Main_Init(), and R_DrawModelSurfaces().

◆ r_q1bsp_lightmap_updates_hidden_surfaces

cvar_t r_q1bsp_lightmap_updates_hidden_surfaces = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_hidden_surfaces", "0", "update lightmaps on surfaces that are not visible, so that updates only occur on frames where lightstyles changed value (animation or light switches), only makes sense with combine = 2"}

Definition at line 259 of file gl_rmain.c.

259{CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_hidden_surfaces", "0", "update lightmaps on surfaces that are not visible, so that updates only occur on frames where lightstyles changed value (animation or light switches), only makes sense with combine = 2"};

Referenced by GL_Main_Init(), and R_DrawModelSurfaces().

◆ r_q1bsp_skymasking

cvar_t r_q1bsp_skymasking = {CF_CLIENT, "r_q1bsp_skymasking", "1", "allows sky polygons in quake1 maps to obscure other geometry"}

Definition at line 132 of file gl_rmain.c.

132{CF_CLIENT, "r_q1bsp_skymasking", "1", "allows sky polygons in quake1 maps to obscure other geometry"};

Referenced by GL_Main_Init(), and R_DrawTextureSurfaceList_Sky().

◆ r_queries

◆ r_qwskincache

r_qwskincache_t* r_qwskincache
static

Definition at line 308 of file gl_rmain.c.

Referenced by gl_main_newmap(), gl_main_shutdown(), gl_main_start(), and R_GetCurrentTexture().

◆ r_qwskincache_size

int r_qwskincache_size
static

Definition at line 309 of file gl_rmain.c.

Referenced by gl_main_newmap(), gl_main_shutdown(), gl_main_start(), and R_GetCurrentTexture().

◆ r_refdef

r_refdef_t r_refdef

Definition at line 57 of file gl_rmain.c.

Referenced by CL_Beam_AddPolygons(), CL_Beam_CalculatePositions(), CL_ClearTempEntities(), CL_ExpandCSQCRenderEntities(), CL_Fog_f(), CL_Fog_HeightTexture_f(), CL_Frame(), CL_GetEntityMatrix(), CL_GetTagMatrix(), CL_Init(), CL_LinkNetworkEntity(), CL_Locs_RemoveNearest_f(), CL_MeshEntities_Scene_AddRenderEntity(), CL_NewParticlesFromEffectinfo(), CL_NewTempEntity(), CL_ParseEntityLump(), CL_ParticleEffect_Fallback(), CL_RelinkBeams(), CL_RelinkLightFlashes(), CL_RelinkStaticEntities(), CL_RelinkWorld(), CL_TimeRefresh_f(), CL_UpdateEntityShading(), CL_UpdateEntityShading_Entity(), CL_UpdatePrydonCursor(), CL_UpdateScreen(), CL_UpdateWorld(), CL_VM_UpdateView(), Collision_Cache_Lookup(), CSQC_AddRenderEdict(), CSQC_R_RecalcView(), DrawQ_Finish(), DrawQ_FlushUI(), DrawQ_RecalcView(), DrawQ_SetClipArea(), DrawQ_Start(), FOG_clear(), gl_main_start(), Mod_BSP_LightPoint_RecursiveBSPNode(), Mod_Mesh_Finalize(), MP_Draw(), R_AnimCache_CacheVisibleEntities(), R_AnimCache_ClearCache(), R_AnimCache_GetEntity(), R_BeginCoronaQuery(), R_BlendView(), R_BlendView_IsTrivial(), R_Bloom_MakeTexture(), R_Bloom_StartFrame(), R_BufferData_Store(), R_BuildFogHeightTexture(), R_BuildFogTexture(), R_BuildLightMap(), R_CalcBeam_Vertex3f(), R_CanSeeBox(), R_ClearScreen(), R_CompleteLightPoint(), R_CullFrustum(), R_DebugLine(), R_DecalSystem_ApplySplatEntities(), R_DrawBBoxMesh(), R_DrawBrushModelsSky(), R_DrawCorona(), R_DrawDebugModel(), R_DrawExplosion_TransparentCallback(), R_DrawLoc_Callback(), R_DrawModelDecals(), R_DrawModelDecals_Entity(), R_DrawModelDecals_FadeEntity(), R_DrawModels(), R_DrawModelsAddWaterPlanes(), R_DrawModelsDebug(), R_DrawModelsDepth(), R_DrawModelSurfaces(), R_DrawModelTextureSurfaceList(), R_DrawNoModel_TransparentCallback(), R_DrawParticle_TransparentCallback(), R_DrawParticles(), R_DrawPortal_Callback(), R_DrawPortals(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Envmap_f(), R_FrameData_Alloc(), R_GetCurrentTexture(), R_GetScenePointer(), R_HDR_UpdateIrisAdaptation(), R_ListWorldTextures_f(), R_Main_FreeViewCache(), R_Main_ResizeViewCache(), R_Mesh_Draw(), R_Mesh_UpdateMeshBuffer(), R_MeshQueue_AddTransparent(), R_MeshQueue_BeginScene(), R_Mod_DrawAddWaterPlanes(), R_Mod_DrawDepth(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Mod_GetLightInfo(), R_Model_Sprite_Draw_TransparentCallback(), R_MotionBlurView(), R_ProcessTransparentTextureSurfaceList(), R_RenderScene(), R_RenderTarget_Get(), R_RenderView(), R_RenderView_UpdateViewVectors(), R_RenderWaterPlanes(), R_ReplaceWorldTexture_f(), R_ResetViewRendering2D_Common(), R_ResetViewRendering3D(), R_RTLight_Compile(), R_ScissorForBBox(), R_SelectScene(), R_SetupShader_DeferredLight(), R_SetupShader_Surface(), R_SetupView(), R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_BounceGrid_CheckEnable(), R_Shadow_BounceGrid_UpdateSpacing(), R_Shadow_ClearShadowMapTexture(), R_Shadow_ClearStencil(), R_Shadow_ComputeShadowCasterCullingPlanes(), R_Shadow_CullFrustumSides(), R_Shadow_DrawCoronas(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLight(), R_Shadow_DrawLightShadowMaps(), R_Shadow_DrawLightSprite_TransparentCallback(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawPrepass(), R_Shadow_DrawShadowMaps(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), R_Shadow_PrepareLight(), R_Shadow_PrepareLights(), R_Shadow_PrepareModelShadows(), R_Shadow_RenderMode_Begin(), R_Shadow_RenderMode_DrawDeferredLight(), R_Shadow_RenderMode_End(), R_Shadow_RenderMode_Lighting(), R_Shadow_RenderMode_Reset(), R_Shadow_RenderMode_ShadowMap(), R_Shadow_RenderMode_VisibleLighting(), R_Shadow_ScissorForBBox(), R_Shadow_SelectLightInView(), R_Shadow_SetCursorLocationForView(), R_Shadow_UpdateBounceGridTexture(), R_Sky(), R_SkySphere(), R_SkyStartFrame(), R_SortEntities(), R_Stain(), R_TimeReport_BeginFrame(), R_TimeReport_EndFrame(), R_TrackSprite(), R_UpdateFog(), R_UpdateVariables(), R_View_SetFrustum(), R_View_Update(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), R_View_WorldVisibility_CullSurfaces(), R_Water_AddWaterPlane(), R_Water_ProcessPlanes(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), RSurf_DrawBatch(), RSurf_FogPoint(), RSurf_FogVertex(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), Sbar_ShowFPS(), SCR_DrawScreen(), V_CalcIntermissionRefdef(), V_CalcRefdef(), V_CalcRefdefUsing(), V_CalcViewBlend(), V_MakeViewIsometric(), VM_CL_getlight(), VM_CL_project(), VM_CL_R_AddDynamicLight(), VM_CL_R_ClearScene(), VM_CL_R_RenderScene(), VM_CL_R_SetView(), and VM_CL_unproject().

◆ r_rendertarget_debug

cvar_t r_rendertarget_debug = {CF_CLIENT, "r_rendertarget_debug", "-1", "replaces the view with the contents of the specified render target (by number - note that these can fluctuate depending on scene)"}

Definition at line 161 of file gl_rmain.c.

161{CF_CLIENT, "r_rendertarget_debug", "-1", "replaces the view with the contents of the specified render target (by number - note that these can fluctuate depending on scene)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_savedds

qbool r_savedds
static

Definition at line 51 of file gl_rmain.c.

Referenced by gl_main_start(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_scenes_store

r_refdef_scene_t r_scenes_store[RST_COUNT]
static

Definition at line 5575 of file gl_rmain.c.

Referenced by R_GetScenePointer(), and R_SelectScene().

◆ r_screenvertex3f

const float r_screenvertex3f
Initial value:
=
{
0, 0, 0,
1, 0, 0,
1, 1, 0,
0, 1, 0
}

vertex coordinates for a quad that covers the screen exactly

Definition at line 313 of file gl_rmain.c.

314{
315 0, 0, 0,
316 1, 0, 0,
317 1, 1, 0,
318 0, 1, 0
319};

Referenced by R_BlendView(), R_Bloom_MakeTexture(), and R_MotionBlurView().

◆ r_shadow_bouncegrid

cvar_t r_shadow_bouncegrid
extern

Definition at line 198 of file r_shadow.c.

198{CF_CLIENT | CF_ARCHIVE, "r_shadow_bouncegrid", "0", "perform particle tracing for indirect lighting (Global Illumination / radiosity) using a 3D texture covering the scene, only active on levels with realtime lights active (r_shadow_realtime_world is usually required for these)"};

Referenced by R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_BounceGrid_CheckEnable(), R_Shadow_BounceGrid_GenerateSettings(), R_Shadow_Init(), and R_Shadow_PrepareLight().

◆ r_shadow_occlusion_buf

unsigned int r_shadow_occlusion_buf
extern

Definition at line 136 of file r_shadow.c.

Referenced by gl_main_shutdown(), and R_DrawCorona().

◆ r_shadow_prepasslightingdiffusetexture

rtexture_t* r_shadow_prepasslightingdiffusetexture
extern

Definition at line 121 of file r_shadow.c.

Referenced by R_SetupShader_Surface().

◆ r_shadow_prepasslightingspeculartexture

rtexture_t* r_shadow_prepasslightingspeculartexture
extern

Definition at line 122 of file r_shadow.c.

Referenced by R_SetupShader_Surface().

◆ r_shadow_shadowmapatlas_modelshadows_size

int r_shadow_shadowmapatlas_modelshadows_size
extern

◆ r_shadow_shadowmappcf

int r_shadow_shadowmappcf
extern

◆ r_shadow_shadowmapsampler

qbool r_shadow_shadowmapsampler
extern

◆ r_shadow_usingdeferredprepass

qbool r_shadow_usingdeferredprepass
extern

◆ r_shadows

Definition at line 123 of file gl_rmain.c.

123{CF_CLIENT | CF_ARCHIVE, "r_shadows", "0", "casts fake stencil shadows from models onto the world (rtlights are unaffected by this); when set to 2, always cast the shadows in the direction set by r_shadows_throwdirection, otherwise use the model lighting."};

Referenced by GL_Main_Init(), R_Shadow_PrepareModelShadows(), and R_Water_ProcessPlanes().

◆ r_shadows_castfrombmodels

cvar_t r_shadows_castfrombmodels = {CF_CLIENT | CF_ARCHIVE, "r_shadows_castfrombmodels", "0", "do cast shadows from bmodels"}

Definition at line 128 of file gl_rmain.c.

128{CF_CLIENT | CF_ARCHIVE, "r_shadows_castfrombmodels", "0", "do cast shadows from bmodels"};

Referenced by GL_Main_Init(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_darken

cvar_t r_shadows_darken = {CF_CLIENT | CF_ARCHIVE, "r_shadows_darken", "0.5", "how much shadowed areas will be darkened"}

Definition at line 124 of file gl_rmain.c.

124{CF_CLIENT | CF_ARCHIVE, "r_shadows_darken", "0.5", "how much shadowed areas will be darkened"};

Referenced by GL_Main_Init(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadows_drawafterrtlighting

cvar_t r_shadows_drawafterrtlighting = {CF_CLIENT | CF_ARCHIVE, "r_shadows_drawafterrtlighting", "0", "draw fake shadows AFTER realtime lightning is drawn. May be useful for simulating fast sunlight on large outdoor maps with only one noshadow rtlight. The price is less realistic appearance of dynamic light shadows."}

Definition at line 127 of file gl_rmain.c.

127{CF_CLIENT | CF_ARCHIVE, "r_shadows_drawafterrtlighting", "0", "draw fake shadows AFTER realtime lightning is drawn. May be useful for simulating fast sunlight on large outdoor maps with only one noshadow rtlight. The price is less realistic appearance of dynamic light shadows."};

Referenced by GL_Main_Init().

◆ r_shadows_focus

cvar_t r_shadows_focus = {CF_CLIENT | CF_ARCHIVE, "r_shadows_focus", "0 0 0", "offset the shadowed area focus"}

Definition at line 129 of file gl_rmain.c.

129{CF_CLIENT | CF_ARCHIVE, "r_shadows_focus", "0 0 0", "offset the shadowed area focus"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_shadowmapbias

cvar_t r_shadows_shadowmapbias = {CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapbias", "-1", "sets shadowmap bias for fake shadows. -1 sets the value of r_shadow_shadowmapping_bias. Needs shadowmapping ON."}

Definition at line 131 of file gl_rmain.c.

131{CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapbias", "-1", "sets shadowmap bias for fake shadows. -1 sets the value of r_shadow_shadowmapping_bias. Needs shadowmapping ON."};

Referenced by GL_Main_Init(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadows_shadowmapscale

cvar_t r_shadows_shadowmapscale = {CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapscale", "0.25", "higher values increase shadowmap quality at a cost of area covered (multiply global shadowmap precision) for fake shadows. Needs shadowmapping ON."}

Definition at line 130 of file gl_rmain.c.

130{CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapscale", "0.25", "higher values increase shadowmap quality at a cost of area covered (multiply global shadowmap precision) for fake shadows. Needs shadowmapping ON."};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_throwdirection

cvar_t r_shadows_throwdirection = {CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdirection", "0 0 -1", "override throwing direction for r_shadows 2"}

Definition at line 126 of file gl_rmain.c.

126{CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdirection", "0 0 -1", "override throwing direction for r_shadows 2"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_throwdistance

cvar_t r_shadows_throwdistance = {CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdistance", "500", "how far to cast shadows from models"}

Definition at line 125 of file gl_rmain.c.

125{CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdistance", "500", "how far to cast shadows from models"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_showbboxes

cvar_t r_showbboxes = {CF_CLIENT, "r_showbboxes", "0", "shows bounding boxes of server entities, value controls opacity scaling (1 = 10%, 10 = 100%)"}

Definition at line 83 of file gl_rmain.c.

83{CF_CLIENT, "r_showbboxes", "0", "shows bounding boxes of server entities, value controls opacity scaling (1 = 10%, 10 = 100%)"};

Referenced by GL_Main_Init(), R_DrawEntityBBoxes_Callback(), and R_RenderScene().

◆ r_showbboxes_client

cvar_t r_showbboxes_client = {CF_CLIENT, "r_showbboxes_client", "0", "shows bounding boxes of clientside qc entities, value controls opacity scaling (1 = 10%, 10 = 100%)"}

Definition at line 84 of file gl_rmain.c.

84{CF_CLIENT, "r_showbboxes_client", "0", "shows bounding boxes of clientside qc entities, value controls opacity scaling (1 = 10%, 10 = 100%)"};

Referenced by GL_Main_Init(), R_DrawEntityBBoxes_Callback(), and R_RenderScene().

◆ r_showcollisionbrushes

cvar_t r_showcollisionbrushes = {CF_CLIENT, "r_showcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"}

Definition at line 89 of file gl_rmain.c.

89{CF_CLIENT, "r_showcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showcollisionbrushes_polygonfactor

cvar_t r_showcollisionbrushes_polygonfactor = {CF_CLIENT, "r_showcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"}

Definition at line 90 of file gl_rmain.c.

90{CF_CLIENT, "r_showcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"};

Referenced by GL_Main_Init(), and R_DrawDebugModel().

◆ r_showcollisionbrushes_polygonoffset

cvar_t r_showcollisionbrushes_polygonoffset = {CF_CLIENT, "r_showcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"}

Definition at line 91 of file gl_rmain.c.

91{CF_CLIENT, "r_showcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"};

Referenced by GL_Main_Init(), and R_DrawDebugModel().

◆ r_showdisabledepthtest

cvar_t r_showdisabledepthtest = {CF_CLIENT, "r_showdisabledepthtest", "0", "disables depth testing on r_show* cvars, allowing you to see what hidden geometry the graphics card is processing"}

Definition at line 92 of file gl_rmain.c.

92{CF_CLIENT, "r_showdisabledepthtest", "0", "disables depth testing on r_show* cvars, allowing you to see what hidden geometry the graphics card is processing"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), R_DrawEntityBBoxes_Callback(), and R_Shadow_RenderLighting().

◆ r_showlighting

cvar_t r_showlighting = {CF_CLIENT, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"}

Definition at line 88 of file gl_rmain.c.

88{CF_CLIENT, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"};

Referenced by GL_Main_Init(), R_Shadow_DrawLight(), and R_Shadow_RenderMode_VisibleLighting().

◆ r_shownormals

cvar_t r_shownormals = {CF_CLIENT, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"}

Definition at line 87 of file gl_rmain.c.

87{CF_CLIENT, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showoverdraw

cvar_t r_showoverdraw = {CF_CLIENT, "r_showoverdraw", "0", "shows overlapping geometry"}

Definition at line 82 of file gl_rmain.c.

82{CF_CLIENT, "r_showoverdraw", "0", "shows overlapping geometry"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showparticleedges

cvar_t r_showparticleedges = {CF_CLIENT, "r_showparticleedges", "0", "renders a debug outline to show the polygon shape of each particle, for debugging rendering bugs with specific view types"}

Definition at line 94 of file gl_rmain.c.

94{CF_CLIENT, "r_showparticleedges", "0", "renders a debug outline to show the polygon shape of each particle, for debugging rendering bugs with specific view types"};

Referenced by GL_Main_Init(), and R_DrawParticle_TransparentCallback().

◆ r_showspriteedges

cvar_t r_showspriteedges = {CF_CLIENT, "r_showspriteedges", "0", "renders a debug outline to show the polygon shape of each sprite frame rendered (may be 2 or more in case of interpolated animations), for debugging rendering bugs with specific view types"}

Definition at line 93 of file gl_rmain.c.

93{CF_CLIENT, "r_showspriteedges", "0", "renders a debug outline to show the polygon shape of each sprite frame rendered (may be 2 or more in case of interpolated animations), for debugging rendering bugs with specific view types"};

Referenced by GL_Main_Init(), and R_Model_Sprite_Draw_TransparentCallback().

◆ r_showsurfaces

cvar_t r_showsurfaces = {CF_CLIENT, "r_showsurfaces", "0", "1 shows surfaces as different colors, or a value of 3 shows an approximation to vertex or object color (for a very approximate view of the game)"}

Definition at line 85 of file gl_rmain.c.

85{CF_CLIENT, "r_showsurfaces", "0", "1 shows surfaces as different colors, or a value of 3 shows an approximation to vertex or object color (for a very approximate view of the game)"};

Referenced by GL_Main_Init(), R_DrawModelDecals(), R_DrawModelDecals_Entity(), R_DrawModelDecals_FadeEntity(), R_DrawModelSurfaces(), R_DrawModelTextureSurfaceList(), R_DrawTextureSurfaceList_ShowSurfaces(), R_ProcessModelTextureSurfaceList(), R_UpdateVariables(), and R_Water_StartFrame().

◆ r_showtris

cvar_t r_showtris = {CF_CLIENT, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"}

Definition at line 86 of file gl_rmain.c.

86{CF_CLIENT, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_skinframe

◆ r_smoothnormals_areaweighting

cvar_t r_smoothnormals_areaweighting = {CF_CLIENT, "r_smoothnormals_areaweighting", "1", "uses significantly faster (and supposedly higher quality) area-weighted vertex normals and tangent vectors rather than summing normalized triangle normals and tangents"}

Definition at line 229 of file gl_rmain.c.

229{CF_CLIENT, "r_smoothnormals_areaweighting", "1", "uses significantly faster (and supposedly higher quality) area-weighted vertex normals and tangent vectors rather than summing normalized triangle normals and tangents"};

Referenced by GL_Main_Init(), Mod_Alias_MorphMesh_CompileFrames(), Mod_DARKPLACESMODEL_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_LoadFaces(), Mod_Q3BSP_LoadFaces(), Mod_VBSP_LoadFaces(), Mod_ZYMOTICMODEL_Load(), RSurf_ActiveCustomEntity(), and RSurf_PrepareVerticesForBatch().

◆ r_sortentities

cvar_t r_sortentities = {CF_CLIENT, "r_sortentities", "0", "sort entities before drawing (might be faster)"}

Definition at line 110 of file gl_rmain.c.

110{CF_CLIENT, "r_sortentities", "0", "sort entities before drawing (might be faster)"};

Referenced by GL_Main_Init(), and R_RenderView().

◆ r_speeds

cvar_t r_speeds = {CF_CLIENT, "r_speeds","0", "displays rendering statistics and per-subsystem timings"}

Definition at line 111 of file gl_rmain.c.

111{CF_CLIENT, "r_speeds","0", "displays rendering statistics and per-subsystem timings"};

Referenced by CL_UpdateWorld(), GL_Main_Init(), R_DrawModelSurfaces(), R_TimeReport(), R_TimeReport_BeginFrame(), R_TimeReport_EndFrame(), and VID_Finish().

◆ r_surfacelist

const msurface_t** r_surfacelist = NULL

Definition at line 10033 of file gl_rmain.c.

Referenced by R_DrawModelSurfaces().

◆ r_svbsp

svbsp_t r_svbsp

shadow volume bsp struct with automatically growing nodes buffer

Definition at line 268 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), R_Q1BSP_CallRecursiveGetLightInfo(), R_Q1BSP_RecursiveGetLightInfo_BIH(), and R_Q1BSP_RecursiveGetLightInfo_BSP().

◆ r_test

cvar_t r_test = {CF_CLIENT, "r_test", "0", "internal development use only, leave it alone (usually does nothing anyway)"}

Definition at line 235 of file gl_rmain.c.

235{CF_CLIENT, "r_test", "0", "internal development use only, leave it alone (usually does nothing anyway)"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and RSurf_DrawBatch().

◆ r_texture_black

◆ r_texture_blanknormalmap

◆ r_texture_cubemaps

cubemapinfo_t* r_texture_cubemaps[MAX_CUBEMAPS]

Definition at line 295 of file gl_rmain.c.

Referenced by gl_main_start(), and R_GetCubemap().

◆ r_texture_dds_load

cvar_t r_texture_dds_load = {CF_CLIENT | CF_ARCHIVE, "r_texture_dds_load", "0", "load compressed dds/filename.dds texture instead of filename.tga, if the file exists (requires driver support)"}

Definition at line 156 of file gl_rmain.c.

156{CF_CLIENT | CF_ARCHIVE, "r_texture_dds_load", "0", "load compressed dds/filename.dds texture instead of filename.tga, if the file exists (requires driver support)"};

Referenced by GL_Main_Init(), and gl_main_start().

◆ r_texture_dds_save

cvar_t r_texture_dds_save = {CF_CLIENT | CF_ARCHIVE, "r_texture_dds_save", "0", "save compressed dds/filename.dds texture when filename.tga is loaded, so that it can be loaded instead next time"}

Definition at line 157 of file gl_rmain.c.

157{CF_CLIENT | CF_ARCHIVE, "r_texture_dds_save", "0", "save compressed dds/filename.dds texture when filename.tga is loaded, so that it can be loaded instead next time"};

Referenced by GL_Main_Init(), gl_main_start(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_texture_fogattenuation

rtexture_t* r_texture_fogattenuation

◆ r_texture_fogheighttexture

rtexture_t* r_texture_fogheighttexture

◆ r_texture_gammaramps

◆ r_texture_gammaramps_serial

unsigned int r_texture_gammaramps_serial

Definition at line 282 of file gl_rmain.c.

Referenced by R_UpdateVariables().

◆ r_texture_grey128

rtexture_t* r_texture_grey128

◆ r_texture_normalizationcube

rtexture_t* r_texture_normalizationcube

Definition at line 278 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), and R_BuildNormalizationCube().

◆ r_texture_notexture

rtexture_t* r_texture_notexture

Definition at line 276 of file gl_rmain.c.

Referenced by R_BuildNoTexture(), and R_GetCurrentTexture().

◆ r_texture_numcubemaps

int r_texture_numcubemaps

Definition at line 294 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), and R_GetCubemap().

◆ r_texture_reflectcube

rtexture_t* r_texture_reflectcube

Definition at line 284 of file gl_rmain.c.

◆ r_texture_white

◆ r_texture_whitecube

◆ r_textureframe

int r_textureframe = 0

used only by R_GetCurrentTexture, incremented per view and per UI render

Definition at line 45 of file gl_rmain.c.

Referenced by DrawQ_FlushUI(), R_GetCurrentTexture(), and R_RenderView().

◆ r_transparent

cvar_t r_transparent = {CF_CLIENT, "r_transparent", "1", "allows use of transparent surfaces (can be turned off to check performance impact)"}

Definition at line 78 of file gl_rmain.c.

78{CF_CLIENT, "r_transparent", "1", "allows use of transparent surfaces (can be turned off to check performance impact)"};

Referenced by GL_Main_Init(), and R_RenderScene().

◆ r_transparent_alphatocoverage

cvar_t r_transparent_alphatocoverage = {CF_CLIENT, "r_transparent_alphatocoverage", "1", "enables GL_ALPHA_TO_COVERAGE antialiasing technique on alphablend and alphatest surfaces when using vid_samples 2 or higher"}

Definition at line 79 of file gl_rmain.c.

79{CF_CLIENT, "r_transparent_alphatocoverage", "1", "enables GL_ALPHA_TO_COVERAGE antialiasing technique on alphablend and alphatest surfaces when using vid_samples 2 or higher"};

Referenced by GL_Main_Init(), R_GetCurrentTexture(), and R_SetupShader_Surface().

◆ r_transparent_sortarraysize

cvar_t r_transparent_sortarraysize = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortarraysize", "4096", "number of distance-sorting layers"}

Definition at line 143 of file gl_rmain.c.

143{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortarraysize", "4096", "number of distance-sorting layers"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortmaxdist

cvar_t r_transparent_sortmaxdist = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmaxdist", "32768", "upper distance limit for transparent sorting"}

Definition at line 142 of file gl_rmain.c.

142{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmaxdist", "32768", "upper distance limit for transparent sorting"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortmindist

cvar_t r_transparent_sortmindist = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmindist", "0", "lower distance limit for transparent sorting"}

Definition at line 141 of file gl_rmain.c.

141{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmindist", "0", "lower distance limit for transparent sorting"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortsurfacesbynearest

cvar_t r_transparent_sortsurfacesbynearest = {CF_CLIENT, "r_transparent_sortsurfacesbynearest", "1", "sort entity and world surfaces by nearest point on bounding box instead of using the center of the bounding box, usually reduces sorting artifacts"}

Definition at line 80 of file gl_rmain.c.

80{CF_CLIENT, "r_transparent_sortsurfacesbynearest", "1", "sort entity and world surfaces by nearest point on bounding box instead of using the center of the bounding box, usually reduces sorting artifacts"};

Referenced by GL_Main_Init(), R_Mod_DrawLight(), and R_ProcessTransparentTextureSurfaceList().

◆ r_transparent_useplanardistance

cvar_t r_transparent_useplanardistance = {CF_CLIENT, "r_transparent_useplanardistance", "0", "sort transparent meshes by distance from view plane rather than spherical distance to the chosen point"}

Definition at line 81 of file gl_rmain.c.

81{CF_CLIENT, "r_transparent_useplanardistance", "0", "sort transparent meshes by distance from view plane rather than spherical distance to the chosen point"};

Referenced by GL_Main_Init(), and R_MeshQueue_AddTransparent().

◆ r_transparentdepthmasking

cvar_t r_transparentdepthmasking = {CF_CLIENT | CF_ARCHIVE, "r_transparentdepthmasking", "0", "enables depth writes on transparent meshes whose materially is normally opaque, this prevents seeing the inside of a transparent mesh"}

Definition at line 140 of file gl_rmain.c.

140{CF_CLIENT | CF_ARCHIVE, "r_transparentdepthmasking", "0", "enables depth writes on transparent meshes whose materially is normally opaque, this prevents seeing the inside of a transparent mesh"};

Referenced by GL_Main_Init(), R_DrawSurface_TransparentCallback(), and R_GetCurrentTexture().

◆ r_uniformbufferalignment

int r_uniformbufferalignment = 32

Definition at line 270 of file gl_rmain.c.

Referenced by gl_main_start(), and R_BufferData_Store().

◆ r_usedepthtextures

cvar_t r_usedepthtextures = {CF_CLIENT | CF_ARCHIVE, "r_usedepthtextures", "1", "use depth texture instead of depth renderbuffer where possible, uses less video memory but may render slower (or faster) depending on hardware"}

Definition at line 159 of file gl_rmain.c.

159{CF_CLIENT | CF_ARCHIVE, "r_usedepthtextures", "1", "use depth texture instead of depth renderbuffer where possible, uses less video memory but may render slower (or faster) depending on hardware"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_useinfinitefarclip

cvar_t r_useinfinitefarclip = {CF_CLIENT | CF_ARCHIVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"}

Definition at line 73 of file gl_rmain.c.

73{CF_CLIENT | CF_ARCHIVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"};

Referenced by GL_Main_Init(), and R_SetupView().

◆ r_viewfbo

cvar_t r_viewfbo = {CF_CLIENT | CF_ARCHIVE, "r_viewfbo", "0", "enables use of an 8bit (1) or 16bit (2) or 32bit (3) per component float framebuffer render, which may be at a different resolution than the video mode; the default setting of 0 uses a framebuffer render when required, and renders directly to the screen otherwise"}

Definition at line 160 of file gl_rmain.c.

160{CF_CLIENT | CF_ARCHIVE, "r_viewfbo", "0", "enables use of an 8bit (1) or 16bit (2) or 32bit (3) per component float framebuffer render, which may be at a different resolution than the video mode; the default setting of 0 uses a framebuffer render when required, and renders directly to the screen otherwise"};

Referenced by GL_Main_Init(), R_BlendView_IsTrivial(), R_Bloom_StartFrame(), and VID_Mode().

◆ r_viewscale

cvar_t r_viewscale = {CF_CLIENT | CF_ARCHIVE, "r_viewscale", "1", "scaling factor for resolution of the fbo rendering method, must be > 0, can be above 1 for a costly antialiasing behavior, typical values are 0.5 for 1/4th as many pixels rendered, or 1 for normal rendering"}

Definition at line 162 of file gl_rmain.c.

162{CF_CLIENT | CF_ARCHIVE, "r_viewscale", "1", "scaling factor for resolution of the fbo rendering method, must be > 0, can be above 1 for a costly antialiasing behavior, typical values are 0.5 for 1/4th as many pixels rendered, or 1 for normal rendering"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling

cvar_t r_viewscale_fpsscaling = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling", "0", "change resolution based on framerate"}

Definition at line 163 of file gl_rmain.c.

163{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling", "0", "change resolution based on framerate"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_min

cvar_t r_viewscale_fpsscaling_min = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_min", "0.0625", "worst acceptable quality"}

Definition at line 164 of file gl_rmain.c.

164{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_min", "0.0625", "worst acceptable quality"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_multiply

cvar_t r_viewscale_fpsscaling_multiply = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_multiply", "5", "adjust quality up or down by the frametime difference from 1.0/target, multiplied by this factor"}

Definition at line 165 of file gl_rmain.c.

165{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_multiply", "5", "adjust quality up or down by the frametime difference from 1.0/target, multiplied by this factor"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_stepmax

cvar_t r_viewscale_fpsscaling_stepmax = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepmax", "1.00", "largest adjustment to hit the target framerate (this value prevents wild overshooting of the estimate)"}

Definition at line 167 of file gl_rmain.c.

167{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepmax", "1.00", "largest adjustment to hit the target framerate (this value prevents wild overshooting of the estimate)"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_stepsize

cvar_t r_viewscale_fpsscaling_stepsize = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepsize", "0.01", "smallest adjustment to hit the target framerate (this value prevents minute oscillations)"}

Definition at line 166 of file gl_rmain.c.

166{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepsize", "0.01", "smallest adjustment to hit the target framerate (this value prevents minute oscillations)"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_target

cvar_t r_viewscale_fpsscaling_target = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_target", "70", "desired framerate"}

Definition at line 168 of file gl_rmain.c.

168{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_target", "70", "desired framerate"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_water

cvar_t r_water = {CF_CLIENT | CF_ARCHIVE, "r_water", "0", "whether to use reflections and refraction on water surfaces (note: r_wateralpha must be set below 1)"}

Definition at line 192 of file gl_rmain.c.

192{CF_CLIENT | CF_ARCHIVE, "r_water", "0", "whether to use reflections and refraction on water surfaces (note: r_wateralpha must be set below 1)"};

Referenced by GL_Main_Init(), R_GetCurrentTexture(), R_Water_ProcessPlanes(), and R_Water_StartFrame().

◆ r_water_cameraentitiesonly

cvar_t r_water_cameraentitiesonly = {CF_CLIENT | CF_ARCHIVE, "r_water_cameraentitiesonly", "0", "whether to only show QC-defined reflections/refractions (typically used for camera- or portal-like effects)"}

Definition at line 193 of file gl_rmain.c.

193{CF_CLIENT | CF_ARCHIVE, "r_water_cameraentitiesonly", "0", "whether to only show QC-defined reflections/refractions (typically used for camera- or portal-like effects)"};

Referenced by GL_Main_Init(), and R_Water_ProcessPlanes().

◆ r_water_clippingplanebias

cvar_t r_water_clippingplanebias = {CF_CLIENT | CF_ARCHIVE, "r_water_clippingplanebias", "1", "a rather technical setting which avoids black pixels around water edges"}

Definition at line 194 of file gl_rmain.c.

194{CF_CLIENT | CF_ARCHIVE, "r_water_clippingplanebias", "1", "a rather technical setting which avoids black pixels around water edges"};

Referenced by GL_Main_Init(), and R_SetupView().

◆ r_water_hideplayer

cvar_t r_water_hideplayer = {CF_CLIENT | CF_ARCHIVE, "r_water_hideplayer", "0", "if set to 1 then player will be hidden in refraction views, if set to 2 then player will also be hidden in reflection views, player is always visible in camera views"}

Definition at line 200 of file gl_rmain.c.

200{CF_CLIENT | CF_ARCHIVE, "r_water_hideplayer", "0", "if set to 1 then player will be hidden in refraction views, if set to 2 then player will also be hidden in reflection views, player is always visible in camera views"};

Referenced by GL_Main_Init(), and R_Water_ProcessPlanes().

◆ r_water_lowquality

cvar_t r_water_lowquality = {CF_CLIENT, "r_water_lowquality", "0", "special option to accelerate water rendering: 1 disables all dynamic lights, 2 disables particles too"}

Definition at line 199 of file gl_rmain.c.

199{CF_CLIENT, "r_water_lowquality", "0", "special option to accelerate water rendering: 1 disables all dynamic lights, 2 disables particles too"};

Referenced by GL_Main_Init(), and R_Water_ProcessPlanes().

◆ r_water_reflectdistort

cvar_t r_water_reflectdistort = {CF_CLIENT | CF_ARCHIVE, "r_water_reflectdistort", "0.01", "how much water reflections shimmer"}

Definition at line 197 of file gl_rmain.c.

197{CF_CLIENT | CF_ARCHIVE, "r_water_reflectdistort", "0.01", "how much water reflections shimmer"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_water_refractdistort

cvar_t r_water_refractdistort = {CF_CLIENT | CF_ARCHIVE, "r_water_refractdistort", "0.01", "how much water refractions shimmer"}

Definition at line 196 of file gl_rmain.c.

196{CF_CLIENT | CF_ARCHIVE, "r_water_refractdistort", "0.01", "how much water refractions shimmer"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_water_resolutionmultiplier

cvar_t r_water_resolutionmultiplier = {CF_CLIENT | CF_ARCHIVE, "r_water_resolutionmultiplier", "0.5", "multiplier for screen resolution when rendering refracted/reflected scenes, 1 is full quality, lower values are faster"}

Definition at line 195 of file gl_rmain.c.

195{CF_CLIENT | CF_ARCHIVE, "r_water_resolutionmultiplier", "0.5", "multiplier for screen resolution when rendering refracted/reflected scenes, 1 is full quality, lower values are faster"};

Referenced by GL_Main_Init(), and R_Water_StartFrame().

◆ r_water_scissormode

cvar_t r_water_scissormode = {CF_CLIENT, "r_water_scissormode", "3", "scissor (1) or cull (2) or both (3) water renders"}

Definition at line 198 of file gl_rmain.c.

198{CF_CLIENT, "r_water_scissormode", "3", "scissor (1) or cull (2) or both (3) water renders"};

Referenced by GL_Main_Init(), and R_Water_ProcessPlanes().

◆ r_wateralpha

cvar_t r_wateralpha = {CF_CLIENT | CF_ARCHIVE, "r_wateralpha","1", "opacity of water polygons"}

◆ r_waterscroll

cvar_t r_waterscroll = {CF_CLIENT | CF_ARCHIVE, "r_waterscroll", "1", "makes water scroll around, value controls how much"}

Definition at line 206 of file gl_rmain.c.

206{CF_CLIENT | CF_ARCHIVE, "r_waterscroll", "1", "makes water scroll around, value controls how much"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and R_RenderScene().

◆ r_waterscrollmatrix

matrix4x4_t r_waterscrollmatrix

Definition at line 5402 of file gl_rmain.c.

Referenced by R_GetCurrentTexture(), R_RenderScene(), and R_tcMod_ApplyToMatrix().

◆ rsurface

rsurfacestate_t rsurface

Definition at line 6955 of file gl_rmain.c.

Referenced by R_DecalSystem_SplatEntity(), R_DecalSystem_SplatTriangle(), R_DrawCustomSurface_Texture(), R_DrawDebugModel(), R_DrawModelDecals_Entity(), R_DrawModelSurfaces(), R_DrawNoModel(), R_DrawNoModel_TransparentCallback(), R_DrawPortals(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_GL20(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_EvaluateQ3WaveFunc(), R_GetCurrentTexture(), R_Mod_DrawAddWaterPlanes(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Mod_GetLightInfo(), R_Model_Sprite_Draw(), R_Model_Sprite_Draw_TransparentCallback(), R_ProcessModelTextureSurfaceList(), R_ProcessTransparentTextureSurfaceList(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), R_RenderView(), R_SetupShader_DeferredLight(), R_SetupShader_DepthOrShadow(), R_SetupShader_Surface(), R_Shadow_DrawEntityLight(), R_Shadow_DrawEntityShadow(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), R_Shadow_RenderLighting(), R_Shadow_RenderLighting_VisibleLighting(), R_Shadow_RenderMode_ActiveLight(), R_Shadow_RenderMode_DrawDeferredLight(), R_Shadow_RenderMode_ShadowMap(), R_Shadow_SetShadowmapParametersForLight(), R_Shadow_SetupEntityLight(), R_tcMod_ApplyToMatrix(), R_TestQ3WaveFunc(), R_Water_AddWaterPlane(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), RSurf_DrawBatch(), RSurf_FindWaterPlaneForSurface(), RSurf_FogVertex(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), and RSurf_UploadBuffersForBatch().

◆ shadermodeinfo

Initial value:
=
{
{
{"combined", "glsl", builtinshaderstrings, "#define MODE_GENERIC\n", " generic"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_POSTPROCESS\n", " postprocess"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_DEPTH_OR_SHADOW\n", " depth/shadow"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_FLATCOLOR\n", " flatcolor"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_VERTEXCOLOR\n", " vertexcolor"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTMAP\n", " lightmap"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_MODELSPACE\n", " lightdirectionmap_modelspace"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n", " lightdirectionmap_tangentspace"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP\n", " lightdirectionmap_forced_lightmap"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR\n", " lightdirectionmap_forced_vertexcolor"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTGRID\n", " lightgrid"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTION\n", " lightdirection"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTSOURCE\n", " lightsource"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_REFRACTION\n", " refraction"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_WATER\n", " water"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_DEFERREDGEOMETRY\n", " deferredgeometry"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_DEFERREDLIGHTSOURCE\n", " deferredlightsource"},
},
}
static const char * builtinshaderstrings[]
Definition gl_rmain.c:596

Definition at line 662 of file gl_rmain.c.

663{
664 // SHADERLANGUAGE_GLSL
665 {
666 {"combined", "glsl", builtinshaderstrings, "#define MODE_GENERIC\n", " generic"},
667 {"combined", "glsl", builtinshaderstrings, "#define MODE_POSTPROCESS\n", " postprocess"},
668 {"combined", "glsl", builtinshaderstrings, "#define MODE_DEPTH_OR_SHADOW\n", " depth/shadow"},
669 {"combined", "glsl", builtinshaderstrings, "#define MODE_FLATCOLOR\n", " flatcolor"},
670 {"combined", "glsl", builtinshaderstrings, "#define MODE_VERTEXCOLOR\n", " vertexcolor"},
671 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTMAP\n", " lightmap"},
672 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_MODELSPACE\n", " lightdirectionmap_modelspace"},
673 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n", " lightdirectionmap_tangentspace"},
674 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP\n", " lightdirectionmap_forced_lightmap"},
675 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR\n", " lightdirectionmap_forced_vertexcolor"},
676 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTGRID\n", " lightgrid"},
677 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTION\n", " lightdirection"},
678 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTSOURCE\n", " lightsource"},
679 {"combined", "glsl", builtinshaderstrings, "#define MODE_REFRACTION\n", " refraction"},
680 {"combined", "glsl", builtinshaderstrings, "#define MODE_WATER\n", " water"},
681 {"combined", "glsl", builtinshaderstrings, "#define MODE_DEFERREDGEOMETRY\n", " deferredgeometry"},
682 {"combined", "glsl", builtinshaderstrings, "#define MODE_DEFERREDLIGHTSOURCE\n", " deferredlightsource"},
683 },
684};

Referenced by R_GLSL_CompilePermutation(), R_GLSL_DumpShader_f(), and R_InitShaderModeInfo().

◆ shaderpermutationinfo

Definition at line 625 of file gl_rmain.c.

626{
627 {"#define USEDIFFUSE\n", " diffuse"},
628 {"#define USEVERTEXTEXTUREBLEND\n", " vertextextureblend"},
629 {"#define USEVIEWTINT\n", " viewtint"},
630 {"#define USECOLORMAPPING\n", " colormapping"},
631 {"#define USESATURATION\n", " saturation"},
632 {"#define USEFOGINSIDE\n", " foginside"},
633 {"#define USEFOGOUTSIDE\n", " fogoutside"},
634 {"#define USEFOGHEIGHTTEXTURE\n", " fogheighttexture"},
635 {"#define USEFOGALPHAHACK\n", " fogalphahack"},
636 {"#define USEGAMMARAMPS\n", " gammaramps"},
637 {"#define USECUBEFILTER\n", " cubefilter"},
638 {"#define USEGLOW\n", " glow"},
639 {"#define USEBLOOM\n", " bloom"},
640 {"#define USESPECULAR\n", " specular"},
641 {"#define USEPOSTPROCESSING\n", " postprocessing"},
642 {"#define USEREFLECTION\n", " reflection"},
643 {"#define USEOFFSETMAPPING\n", " offsetmapping"},
644 {"#define USEOFFSETMAPPING_RELIEFMAPPING\n", " reliefmapping"},
645 {"#define USESHADOWMAP2D\n", " shadowmap2d"},
646 {"#define USESHADOWMAPVSDCT\n", " shadowmapvsdct"}, // TODO make this a static parm
647 {"#define USESHADOWMAPORTHO\n", " shadowmaportho"},
648 {"#define USEDEFERREDLIGHTMAP\n", " deferredlightmap"},
649 {"#define USEALPHAKILL\n", " alphakill"},
650 {"#define USEREFLECTCUBE\n", " reflectcube"},
651 {"#define USENORMALMAPSCROLLBLEND\n", " normalmapscrollblend"},
652 {"#define USEBOUNCEGRID\n", " bouncegrid"},
653 {"#define USEBOUNCEGRIDDIRECTIONAL\n", " bouncegriddirectional"}, // TODO make this a static parm
654 {"#define USETRIPPY\n", " trippy"},
655 {"#define USEDEPTHRGB\n", " depthrgb"},
656 {"#define USEALPHAGENVERTEX\n", " alphagenvertex"},
657 {"#define USESKELETAL\n", " skeletal"},
658 {"#define USEOCCLUDE\n", " occlude"}
659};

Referenced by R_GLSL_CompilePermutation(), and R_GLSL_DumpShader_f().

◆ shaderstaticparms_count

int shaderstaticparms_count = 0
static

Definition at line 854 of file gl_rmain.c.

Referenced by R_CompileShader_AddStaticParms(), and R_GLSL_CompilePermutation().

◆ shaderstaticparmstrings_list

const char* shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT]
static

Definition at line 853 of file gl_rmain.c.

Referenced by R_GLSL_CompilePermutation().

◆ suffix

suffixinfo_t suffix[3][6]
static
Initial value:
=
{
{
{"px", false, false, false},
{"nx", false, false, false},
{"py", false, false, false},
{"ny", false, false, false},
{"pz", false, false, false},
{"nz", false, false, false}
},
{
{"posx", false, false, false},
{"negx", false, false, false},
{"posy", false, false, false},
{"negy", false, false, false},
{"posz", false, false, false},
{"negz", false, false, false}
},
{
{"rt", true, false, true},
{"lf", false, true, true},
{"ft", true, true, false},
{"bk", false, false, false},
{"up", true, false, true},
{"dn", true, false, true}
}
}

Definition at line 2877 of file gl_rmain.c.

2878{
2879 {
2880 {"px", false, false, false},
2881 {"nx", false, false, false},
2882 {"py", false, false, false},
2883 {"ny", false, false, false},
2884 {"pz", false, false, false},
2885 {"nz", false, false, false}
2886 },
2887 {
2888 {"posx", false, false, false},
2889 {"negx", false, false, false},
2890 {"posy", false, false, false},
2891 {"negy", false, false, false},
2892 {"posz", false, false, false},
2893 {"negz", false, false, false}
2894 },
2895 {
2896 {"rt", true, false, true},
2897 {"lf", false, true, true},
2898 {"ft", true, true, false},
2899 {"bk", false, false, false},
2900 {"up", true, false, true},
2901 {"dn", true, false, true}
2902 }
2903};

Referenced by R_LoadCubemap().

◆ v_flipped_state

qbool v_flipped_state
extern

Definition at line 17 of file gl_backend.c.

Referenced by GL_CullFace(), and GL_SetMirrorState().

◆ v_glslgamma_2d

cvar_t v_glslgamma_2d
extern

Definition at line 187 of file vid_shared.c.

187{CF_CLIENT | CF_ARCHIVE, "v_glslgamma_2d", "1", "applies GLSL gamma to 2d pictures (HUD, fonts)"};

Referenced by R_SetupShader_Generic(), and VID_Shared_Init().

◆ v_isometric

cvar_t v_isometric
extern

Definition at line 97 of file view.c.

97{CF_CLIENT, "v_isometric", "0", "changes view to isometric (non-perspective)"};

Referenced by R_RenderView(), and V_Init().

◆ viewscalefpsadjusted

float viewscalefpsadjusted = 1.0f

Definition at line 4390 of file gl_rmain.c.

Referenced by R_Bloom_StartFrame().